Add "store create time" parameter (docs to follow)
[Samba/fernandojvsilva.git] / source3 / param / loadparm.c
blob35984716a26f8c3840e416246415f89e08dd37a5
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_HTTPCONNECTENCRYPT
58 #include <cups/http.h>
59 #endif
61 bool bLoaded = False;
63 extern enum protocol_types Protocol;
64 extern userdom_struct current_user_info;
66 #ifndef GLOBAL_NAME
67 #define GLOBAL_NAME "global"
68 #endif
70 #ifndef PRINTERS_NAME
71 #define PRINTERS_NAME "printers"
72 #endif
74 #ifndef HOMES_NAME
75 #define HOMES_NAME "homes"
76 #endif
78 /* the special value for the include parameter
79 * to be interpreted not as a file name but to
80 * trigger loading of the global smb.conf options
81 * from registry. */
82 #ifndef INCLUDE_REGISTRY_NAME
83 #define INCLUDE_REGISTRY_NAME "registry"
84 #endif
86 static bool in_client = False; /* Not in the client by default */
87 static struct smbconf_csn conf_last_csn;
89 #define CONFIG_BACKEND_FILE 0
90 #define CONFIG_BACKEND_REGISTRY 1
92 static int config_backend = CONFIG_BACKEND_FILE;
94 /* some helpful bits */
95 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
96 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
98 #define USERSHARE_VALID 1
99 #define USERSHARE_PENDING_DELETE 2
101 static bool defaults_saved = False;
103 struct param_opt_struct {
104 struct param_opt_struct *prev, *next;
105 char *key;
106 char *value;
107 char **list;
111 * This structure describes global (ie., server-wide) parameters.
113 struct global {
114 int ConfigBackend;
115 char *smb_ports;
116 char *dos_charset;
117 char *unix_charset;
118 char *display_charset;
119 char *szPrintcapname;
120 char *szAddPortCommand;
121 char *szEnumPortsCommand;
122 char *szAddPrinterCommand;
123 char *szDeletePrinterCommand;
124 char *szOs2DriverMap;
125 char *szLockDir;
126 char *szStateDir;
127 char *szCacheDir;
128 char *szPidDir;
129 char *szRootdir;
130 char *szDefaultService;
131 char *szGetQuota;
132 char *szSetQuota;
133 char *szMsgCommand;
134 char *szServerString;
135 char *szAutoServices;
136 char *szPasswdProgram;
137 char *szPasswdChat;
138 char *szLogFile;
139 char *szConfigFile;
140 char *szSMBPasswdFile;
141 char *szPrivateDir;
142 char *szPassdbBackend;
143 char **szPreloadModules;
144 char *szPasswordServer;
145 char *szSocketOptions;
146 char *szRealm;
147 char *szAfsUsernameMap;
148 int iAfsTokenLifetime;
149 char *szLogNtTokenCommand;
150 char *szUsernameMap;
151 char *szLogonScript;
152 char *szLogonPath;
153 char *szLogonDrive;
154 char *szLogonHome;
155 char **szWINSservers;
156 char **szInterfaces;
157 char *szRemoteAnnounce;
158 char *szRemoteBrowseSync;
159 char *szSocketAddress;
160 char *szNISHomeMapName;
161 char *szAnnounceVersion; /* This is initialised in init_globals */
162 char *szWorkgroup;
163 char *szNetbiosName;
164 char **szNetbiosAliases;
165 char *szNetbiosScope;
166 char *szNameResolveOrder;
167 char *szPanicAction;
168 char *szAddUserScript;
169 char *szRenameUserScript;
170 char *szDelUserScript;
171 char *szAddGroupScript;
172 char *szDelGroupScript;
173 char *szAddUserToGroupScript;
174 char *szDelUserFromGroupScript;
175 char *szSetPrimaryGroupScript;
176 char *szAddMachineScript;
177 char *szShutdownScript;
178 char *szAbortShutdownScript;
179 char *szUsernameMapScript;
180 char *szCheckPasswordScript;
181 char *szWINSHook;
182 char *szUtmpDir;
183 char *szWtmpDir;
184 bool bUtmp;
185 char *szIdmapUID;
186 char *szIdmapGID;
187 bool bPassdbExpandExplicit;
188 int AlgorithmicRidBase;
189 char *szTemplateHomedir;
190 char *szTemplateShell;
191 char *szWinbindSeparator;
192 bool bWinbindEnumUsers;
193 bool bWinbindEnumGroups;
194 bool bWinbindUseDefaultDomain;
195 bool bWinbindTrustedDomainsOnly;
196 bool bWinbindNestedGroups;
197 int winbind_expand_groups;
198 bool bWinbindRefreshTickets;
199 bool bWinbindOfflineLogon;
200 bool bWinbindNormalizeNames;
201 bool bWinbindRpcOnly;
202 char *szIdmapBackend;
203 char *szIdmapAllocBackend;
204 char *szAddShareCommand;
205 char *szChangeShareCommand;
206 char *szDeleteShareCommand;
207 char **szEventLogs;
208 char *szGuestaccount;
209 char *szManglingMethod;
210 char **szServicesList;
211 char *szUsersharePath;
212 char *szUsershareTemplateShare;
213 char **szUsersharePrefixAllowList;
214 char **szUsersharePrefixDenyList;
215 int mangle_prefix;
216 int max_log_size;
217 char *szLogLevel;
218 int max_xmit;
219 int max_mux;
220 int max_open_files;
221 int open_files_db_hash_size;
222 int pwordlevel;
223 int unamelevel;
224 int deadtime;
225 bool getwd_cache;
226 int maxprotocol;
227 int minprotocol;
228 int security;
229 char **AuthMethods;
230 bool paranoid_server_security;
231 int maxdisksize;
232 int lpqcachetime;
233 int iMaxSmbdProcesses;
234 bool bDisableSpoolss;
235 int syslog;
236 int os_level;
237 bool enhanced_browsing;
238 int max_ttl;
239 int max_wins_ttl;
240 int min_wins_ttl;
241 int lm_announce;
242 int lm_interval;
243 int announce_as; /* This is initialised in init_globals */
244 int machine_password_timeout;
245 int map_to_guest;
246 int oplock_break_wait_time;
247 int winbind_cache_time;
248 int winbind_reconnect_delay;
249 int winbind_max_idle_children;
250 char **szWinbindNssInfo;
251 int iLockSpinTime;
252 char *szLdapMachineSuffix;
253 char *szLdapUserSuffix;
254 char *szLdapIdmapSuffix;
255 char *szLdapGroupSuffix;
256 int ldap_ssl;
257 bool ldap_ssl_ads;
258 char *szLdapSuffix;
259 char *szLdapAdminDn;
260 int ldap_debug_level;
261 int ldap_debug_threshold;
262 int iAclCompat;
263 char *szCupsServer;
264 int CupsEncrypt;
265 char *szIPrintServer;
266 char *ctdbdSocket;
267 char **szClusterAddresses;
268 bool clustering;
269 int ldap_passwd_sync;
270 int ldap_replication_sleep;
271 int ldap_timeout; /* This is initialised in init_globals */
272 int ldap_connection_timeout;
273 int ldap_page_size;
274 bool ldap_delete_dn;
275 bool bMsAddPrinterWizard;
276 bool bDNSproxy;
277 bool bWINSsupport;
278 bool bWINSproxy;
279 bool bLocalMaster;
280 int iPreferredMaster;
281 int iDomainMaster;
282 bool bDomainLogons;
283 char **szInitLogonDelayedHosts;
284 int InitLogonDelay;
285 bool bEncryptPasswords;
286 bool bUpdateEncrypt;
287 int clientSchannel;
288 int serverSchannel;
289 bool bNullPasswords;
290 bool bObeyPamRestrictions;
291 bool bLoadPrinters;
292 int PrintcapCacheTime;
293 bool bLargeReadwrite;
294 bool bReadRaw;
295 bool bWriteRaw;
296 bool bSyslogOnly;
297 bool bBrowseList;
298 bool bNISHomeMap;
299 bool bTimeServer;
300 bool bBindInterfacesOnly;
301 bool bPamPasswordChange;
302 bool bUnixPasswdSync;
303 bool bPasswdChatDebug;
304 int iPasswdChatTimeout;
305 bool bTimestampLogs;
306 bool bNTSmbSupport;
307 bool bNTPipeSupport;
308 bool bNTStatusSupport;
309 bool bStatCache;
310 int iMaxStatCacheSize;
311 bool bKernelOplocks;
312 bool bAllowTrustedDomains;
313 bool bLanmanAuth;
314 bool bNTLMAuth;
315 bool bUseSpnego;
316 bool bClientLanManAuth;
317 bool bClientNTLMv2Auth;
318 bool bClientPlaintextAuth;
319 bool bClientUseSpnego;
320 bool bDebugPrefixTimestamp;
321 bool bDebugHiresTimestamp;
322 bool bDebugPid;
323 bool bDebugUid;
324 bool bDebugClass;
325 bool bEnableCoreFiles;
326 bool bHostMSDfs;
327 bool bUseMmap;
328 bool bHostnameLookups;
329 bool bUnixExtensions;
330 bool bDisableNetbios;
331 char * szDedicatedKeytabFile;
332 int iKerberosMethod;
333 bool bDeferSharingViolations;
334 bool bEnablePrivileges;
335 bool bASUSupport;
336 bool bUsershareOwnerOnly;
337 bool bUsershareAllowGuests;
338 bool bRegistryShares;
339 int restrict_anonymous;
340 int name_cache_timeout;
341 int client_signing;
342 int server_signing;
343 int client_ldap_sasl_wrapping;
344 int iUsershareMaxShares;
345 int iIdmapCacheTime;
346 int iIdmapNegativeCacheTime;
347 bool bResetOnZeroVC;
348 int iKeepalive;
349 int iminreceivefile;
350 struct param_opt_struct *param_opt;
351 int cups_connection_timeout;
352 char *szSMBPerfcountModule;
353 bool bMapUntrustedToDomain;
354 bool bFakeDirCreateTimes;
357 static struct global Globals;
360 * This structure describes a single service.
362 struct service {
363 bool valid;
364 bool autoloaded;
365 int usershare;
366 struct timespec usershare_last_mod;
367 char *szService;
368 char *szPath;
369 char *szUsername;
370 char **szInvalidUsers;
371 char **szValidUsers;
372 char **szAdminUsers;
373 char *szCopy;
374 char *szInclude;
375 char *szPreExec;
376 char *szPostExec;
377 char *szRootPreExec;
378 char *szRootPostExec;
379 char *szCupsOptions;
380 char *szPrintcommand;
381 char *szLpqcommand;
382 char *szLprmcommand;
383 char *szLppausecommand;
384 char *szLpresumecommand;
385 char *szQueuepausecommand;
386 char *szQueueresumecommand;
387 char *szPrintername;
388 char *szPrintjobUsername;
389 char *szDontdescend;
390 char **szHostsallow;
391 char **szHostsdeny;
392 char *szMagicScript;
393 char *szMagicOutput;
394 char *szVetoFiles;
395 char *szHideFiles;
396 char *szVetoOplockFiles;
397 char *comment;
398 char *force_user;
399 char *force_group;
400 char **readlist;
401 char **writelist;
402 char **printer_admin;
403 char *volume;
404 char *fstype;
405 char **szVfsObjects;
406 char *szMSDfsProxy;
407 char *szAioWriteBehind;
408 char *szDfree;
409 int iMinPrintSpace;
410 int iMaxPrintJobs;
411 int iMaxReportedPrintJobs;
412 int iWriteCacheSize;
413 int iCreate_mask;
414 int iCreate_force_mode;
415 int iSecurity_mask;
416 int iSecurity_force_mode;
417 int iDir_mask;
418 int iDir_force_mode;
419 int iDir_Security_mask;
420 int iDir_Security_force_mode;
421 int iMaxConnections;
422 int iDefaultCase;
423 int iPrinting;
424 int iOplockContentionLimit;
425 int iCSCPolicy;
426 int iBlock_size;
427 int iDfreeCacheTime;
428 bool bPreexecClose;
429 bool bRootpreexecClose;
430 int iCaseSensitive;
431 bool bCasePreserve;
432 bool bShortCasePreserve;
433 bool bHideDotFiles;
434 bool bHideSpecialFiles;
435 bool bHideUnReadable;
436 bool bHideUnWriteableFiles;
437 bool bBrowseable;
438 bool bAccessBasedShareEnum;
439 bool bAvailable;
440 bool bRead_only;
441 bool bNo_set_dir;
442 bool bGuest_only;
443 bool bAdministrative_share;
444 bool bGuest_ok;
445 bool bPrint_ok;
446 bool bMap_system;
447 bool bMap_hidden;
448 bool bMap_archive;
449 bool bStoreCreateTime;
450 bool bStoreDosAttributes;
451 bool bDmapiSupport;
452 bool bLocking;
453 int iStrictLocking;
454 bool bPosixLocking;
455 bool bShareModes;
456 bool bOpLocks;
457 bool bLevel2OpLocks;
458 bool bOnlyUser;
459 bool bMangledNames;
460 bool bWidelinks;
461 bool bSymlinks;
462 bool bSyncAlways;
463 bool bStrictAllocate;
464 bool bStrictSync;
465 char magic_char;
466 struct bitmap *copymap;
467 bool bDeleteReadonly;
468 bool bFakeOplocks;
469 bool bDeleteVetoFiles;
470 bool bDosFilemode;
471 bool bDosFiletimes;
472 bool bDosFiletimeResolution;
473 bool bBlockingLocks;
474 bool bInheritPerms;
475 bool bInheritACLS;
476 bool bInheritOwner;
477 bool bMSDfsRoot;
478 bool bUseClientDriver;
479 bool bDefaultDevmode;
480 bool bForcePrintername;
481 bool bNTAclSupport;
482 bool bForceUnknownAclUser;
483 bool bUseSendfile;
484 bool bProfileAcls;
485 bool bMap_acl_inherit;
486 bool bAfs_Share;
487 bool bEASupport;
488 bool bAclCheckPermissions;
489 bool bAclMapFullControl;
490 bool bAclGroupControl;
491 bool bChangeNotify;
492 bool bKernelChangeNotify;
493 int iallocation_roundup_size;
494 int iAioReadSize;
495 int iAioWriteSize;
496 int iMap_readonly;
497 int iDirectoryNameCacheSize;
498 int ismb_encrypt;
499 struct param_opt_struct *param_opt;
501 char dummy[3]; /* for alignment */
505 /* This is a default service used to prime a services structure */
506 static struct service sDefault = {
507 True, /* valid */
508 False, /* not autoloaded */
509 0, /* not a usershare */
510 {0, }, /* No last mod time */
511 NULL, /* szService */
512 NULL, /* szPath */
513 NULL, /* szUsername */
514 NULL, /* szInvalidUsers */
515 NULL, /* szValidUsers */
516 NULL, /* szAdminUsers */
517 NULL, /* szCopy */
518 NULL, /* szInclude */
519 NULL, /* szPreExec */
520 NULL, /* szPostExec */
521 NULL, /* szRootPreExec */
522 NULL, /* szRootPostExec */
523 NULL, /* szCupsOptions */
524 NULL, /* szPrintcommand */
525 NULL, /* szLpqcommand */
526 NULL, /* szLprmcommand */
527 NULL, /* szLppausecommand */
528 NULL, /* szLpresumecommand */
529 NULL, /* szQueuepausecommand */
530 NULL, /* szQueueresumecommand */
531 NULL, /* szPrintername */
532 NULL, /* szPrintjobUsername */
533 NULL, /* szDontdescend */
534 NULL, /* szHostsallow */
535 NULL, /* szHostsdeny */
536 NULL, /* szMagicScript */
537 NULL, /* szMagicOutput */
538 NULL, /* szVetoFiles */
539 NULL, /* szHideFiles */
540 NULL, /* szVetoOplockFiles */
541 NULL, /* comment */
542 NULL, /* force user */
543 NULL, /* force group */
544 NULL, /* readlist */
545 NULL, /* writelist */
546 NULL, /* printer admin */
547 NULL, /* volume */
548 NULL, /* fstype */
549 NULL, /* vfs objects */
550 NULL, /* szMSDfsProxy */
551 NULL, /* szAioWriteBehind */
552 NULL, /* szDfree */
553 0, /* iMinPrintSpace */
554 1000, /* iMaxPrintJobs */
555 0, /* iMaxReportedPrintJobs */
556 0, /* iWriteCacheSize */
557 0744, /* iCreate_mask */
558 0000, /* iCreate_force_mode */
559 0777, /* iSecurity_mask */
560 0, /* iSecurity_force_mode */
561 0755, /* iDir_mask */
562 0000, /* iDir_force_mode */
563 0777, /* iDir_Security_mask */
564 0, /* iDir_Security_force_mode */
565 0, /* iMaxConnections */
566 CASE_LOWER, /* iDefaultCase */
567 DEFAULT_PRINTING, /* iPrinting */
568 2, /* iOplockContentionLimit */
569 0, /* iCSCPolicy */
570 1024, /* iBlock_size */
571 0, /* iDfreeCacheTime */
572 False, /* bPreexecClose */
573 False, /* bRootpreexecClose */
574 Auto, /* case sensitive */
575 True, /* case preserve */
576 True, /* short case preserve */
577 True, /* bHideDotFiles */
578 False, /* bHideSpecialFiles */
579 False, /* bHideUnReadable */
580 False, /* bHideUnWriteableFiles */
581 True, /* bBrowseable */
582 False, /* bAccessBasedShareEnum */
583 True, /* bAvailable */
584 True, /* bRead_only */
585 True, /* bNo_set_dir */
586 False, /* bGuest_only */
587 False, /* bAdministrative_share */
588 False, /* bGuest_ok */
589 False, /* bPrint_ok */
590 False, /* bMap_system */
591 False, /* bMap_hidden */
592 True, /* bMap_archive */
593 False, /* bStoreCreateTime */
594 False, /* bStoreDosAttributes */
595 False, /* bDmapiSupport */
596 True, /* bLocking */
597 Auto, /* iStrictLocking */
598 True, /* bPosixLocking */
599 True, /* bShareModes */
600 True, /* bOpLocks */
601 True, /* bLevel2OpLocks */
602 False, /* bOnlyUser */
603 True, /* bMangledNames */
604 True, /* bWidelinks */
605 True, /* bSymlinks */
606 False, /* bSyncAlways */
607 False, /* bStrictAllocate */
608 False, /* bStrictSync */
609 '~', /* magic char */
610 NULL, /* copymap */
611 False, /* bDeleteReadonly */
612 False, /* bFakeOplocks */
613 False, /* bDeleteVetoFiles */
614 False, /* bDosFilemode */
615 True, /* bDosFiletimes */
616 False, /* bDosFiletimeResolution */
617 True, /* bBlockingLocks */
618 False, /* bInheritPerms */
619 False, /* bInheritACLS */
620 False, /* bInheritOwner */
621 False, /* bMSDfsRoot */
622 False, /* bUseClientDriver */
623 True, /* bDefaultDevmode */
624 False, /* bForcePrintername */
625 True, /* bNTAclSupport */
626 False, /* bForceUnknownAclUser */
627 False, /* bUseSendfile */
628 False, /* bProfileAcls */
629 False, /* bMap_acl_inherit */
630 False, /* bAfs_Share */
631 False, /* bEASupport */
632 True, /* bAclCheckPermissions */
633 True, /* bAclMapFullControl */
634 False, /* bAclGroupControl */
635 True, /* bChangeNotify */
636 True, /* bKernelChangeNotify */
637 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
638 0, /* iAioReadSize */
639 0, /* iAioWriteSize */
640 MAP_READONLY_YES, /* iMap_readonly */
641 #ifdef BROKEN_DIRECTORY_HANDLING
642 0, /* iDirectoryNameCacheSize */
643 #else
644 100, /* iDirectoryNameCacheSize */
645 #endif
646 Auto, /* ismb_encrypt */
647 NULL, /* Parametric options */
649 "" /* dummy */
652 /* local variables */
653 static struct service **ServicePtrs = NULL;
654 static int iNumServices = 0;
655 static int iServiceIndex = 0;
656 static struct db_context *ServiceHash;
657 static int *invalid_services = NULL;
658 static int num_invalid_services = 0;
659 static bool bInGlobalSection = True;
660 static bool bGlobalOnly = False;
661 static int server_role;
662 static int default_server_announce;
664 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
666 /* prototypes for the special type handlers */
667 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
668 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
669 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
670 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
671 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
672 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
673 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
674 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
675 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
676 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
677 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
678 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
680 static void set_server_role(void);
681 static void set_default_server_announce_type(void);
682 static void set_allowed_client_auth(void);
684 static void *lp_local_ptr(struct service *service, void *ptr);
686 static void add_to_file_list(const char *fname, const char *subfname);
688 static const struct enum_list enum_protocol[] = {
689 {PROTOCOL_SMB2, "SMB2"},
690 {PROTOCOL_NT1, "NT1"},
691 {PROTOCOL_LANMAN2, "LANMAN2"},
692 {PROTOCOL_LANMAN1, "LANMAN1"},
693 {PROTOCOL_CORE, "CORE"},
694 {PROTOCOL_COREPLUS, "COREPLUS"},
695 {PROTOCOL_COREPLUS, "CORE+"},
696 {-1, NULL}
699 static const struct enum_list enum_security[] = {
700 {SEC_SHARE, "SHARE"},
701 {SEC_USER, "USER"},
702 {SEC_SERVER, "SERVER"},
703 {SEC_DOMAIN, "DOMAIN"},
704 #ifdef HAVE_ADS
705 {SEC_ADS, "ADS"},
706 #endif
707 {-1, NULL}
710 static const struct enum_list enum_printing[] = {
711 {PRINT_SYSV, "sysv"},
712 {PRINT_AIX, "aix"},
713 {PRINT_HPUX, "hpux"},
714 {PRINT_BSD, "bsd"},
715 {PRINT_QNX, "qnx"},
716 {PRINT_PLP, "plp"},
717 {PRINT_LPRNG, "lprng"},
718 {PRINT_CUPS, "cups"},
719 {PRINT_IPRINT, "iprint"},
720 {PRINT_LPRNT, "nt"},
721 {PRINT_LPROS2, "os2"},
722 #ifdef DEVELOPER
723 {PRINT_TEST, "test"},
724 {PRINT_VLP, "vlp"},
725 #endif /* DEVELOPER */
726 {-1, NULL}
729 static const struct enum_list enum_ldap_sasl_wrapping[] = {
730 {0, "plain"},
731 {ADS_AUTH_SASL_SIGN, "sign"},
732 {ADS_AUTH_SASL_SEAL, "seal"},
733 {-1, NULL}
736 static const struct enum_list enum_ldap_ssl[] = {
737 {LDAP_SSL_OFF, "no"},
738 {LDAP_SSL_OFF, "off"},
739 {LDAP_SSL_START_TLS, "start tls"},
740 {LDAP_SSL_START_TLS, "start_tls"},
741 {-1, NULL}
744 static const struct enum_list enum_ldap_passwd_sync[] = {
745 {LDAP_PASSWD_SYNC_OFF, "no"},
746 {LDAP_PASSWD_SYNC_OFF, "off"},
747 {LDAP_PASSWD_SYNC_ON, "yes"},
748 {LDAP_PASSWD_SYNC_ON, "on"},
749 {LDAP_PASSWD_SYNC_ONLY, "only"},
750 {-1, NULL}
753 /* Types of machine we can announce as. */
754 #define ANNOUNCE_AS_NT_SERVER 1
755 #define ANNOUNCE_AS_WIN95 2
756 #define ANNOUNCE_AS_WFW 3
757 #define ANNOUNCE_AS_NT_WORKSTATION 4
759 static const struct enum_list enum_announce_as[] = {
760 {ANNOUNCE_AS_NT_SERVER, "NT"},
761 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
762 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
763 {ANNOUNCE_AS_WIN95, "win95"},
764 {ANNOUNCE_AS_WFW, "WfW"},
765 {-1, NULL}
768 static const struct enum_list enum_map_readonly[] = {
769 {MAP_READONLY_NO, "no"},
770 {MAP_READONLY_NO, "false"},
771 {MAP_READONLY_NO, "0"},
772 {MAP_READONLY_YES, "yes"},
773 {MAP_READONLY_YES, "true"},
774 {MAP_READONLY_YES, "1"},
775 {MAP_READONLY_PERMISSIONS, "permissions"},
776 {MAP_READONLY_PERMISSIONS, "perms"},
777 {-1, NULL}
780 static const struct enum_list enum_case[] = {
781 {CASE_LOWER, "lower"},
782 {CASE_UPPER, "upper"},
783 {-1, NULL}
788 static const struct enum_list enum_bool_auto[] = {
789 {False, "No"},
790 {False, "False"},
791 {False, "0"},
792 {True, "Yes"},
793 {True, "True"},
794 {True, "1"},
795 {Auto, "Auto"},
796 {-1, NULL}
799 /* Client-side offline caching policy types */
800 #define CSC_POLICY_MANUAL 0
801 #define CSC_POLICY_DOCUMENTS 1
802 #define CSC_POLICY_PROGRAMS 2
803 #define CSC_POLICY_DISABLE 3
805 static const struct enum_list enum_csc_policy[] = {
806 {CSC_POLICY_MANUAL, "manual"},
807 {CSC_POLICY_DOCUMENTS, "documents"},
808 {CSC_POLICY_PROGRAMS, "programs"},
809 {CSC_POLICY_DISABLE, "disable"},
810 {-1, NULL}
813 /* SMB signing types. */
814 static const struct enum_list enum_smb_signing_vals[] = {
815 {False, "No"},
816 {False, "False"},
817 {False, "0"},
818 {False, "Off"},
819 {False, "disabled"},
820 {True, "Yes"},
821 {True, "True"},
822 {True, "1"},
823 {True, "On"},
824 {True, "enabled"},
825 {Auto, "auto"},
826 {Required, "required"},
827 {Required, "mandatory"},
828 {Required, "force"},
829 {Required, "forced"},
830 {Required, "enforced"},
831 {-1, NULL}
834 /* ACL compatibility options. */
835 static const struct enum_list enum_acl_compat_vals[] = {
836 { ACL_COMPAT_AUTO, "auto" },
837 { ACL_COMPAT_WINNT, "winnt" },
838 { ACL_COMPAT_WIN2K, "win2k" },
839 { -1, NULL}
843 Do you want session setups at user level security with a invalid
844 password to be rejected or allowed in as guest? WinNT rejects them
845 but it can be a pain as it means "net view" needs to use a password
847 You have 3 choices in the setting of map_to_guest:
849 "Never" means session setups with an invalid password
850 are rejected. This is the default.
852 "Bad User" means session setups with an invalid password
853 are rejected, unless the username does not exist, in which case it
854 is treated as a guest login
856 "Bad Password" means session setups with an invalid password
857 are treated as a guest login
859 Note that map_to_guest only has an effect in user or server
860 level security.
863 static const struct enum_list enum_map_to_guest[] = {
864 {NEVER_MAP_TO_GUEST, "Never"},
865 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
866 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
867 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
868 {-1, NULL}
871 /* Config backend options */
873 static const struct enum_list enum_config_backend[] = {
874 {CONFIG_BACKEND_FILE, "file"},
875 {CONFIG_BACKEND_REGISTRY, "registry"},
876 {-1, NULL}
879 /* ADS kerberos ticket verification options */
881 static const struct enum_list enum_kerberos_method[] = {
882 {KERBEROS_VERIFY_SECRETS, "default"},
883 {KERBEROS_VERIFY_SECRETS, "secrets only"},
884 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
885 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
886 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
887 {-1, NULL}
890 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
892 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
893 * screen in SWAT. This is used to exclude parameters as well as to squash all
894 * parameters that have been duplicated by pseudonyms.
896 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
897 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
898 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
899 * respective views.
901 * NOTE2: Handling of duplicated (synonym) parameters:
902 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
903 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
904 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
905 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
908 static struct parm_struct parm_table[] = {
909 {N_("Base Options"), P_SEP, P_SEPARATOR},
912 .label = "dos charset",
913 .type = P_STRING,
914 .p_class = P_GLOBAL,
915 .ptr = &Globals.dos_charset,
916 .special = handle_charset,
917 .enum_list = NULL,
918 .flags = FLAG_ADVANCED
921 .label = "unix charset",
922 .type = P_STRING,
923 .p_class = P_GLOBAL,
924 .ptr = &Globals.unix_charset,
925 .special = handle_charset,
926 .enum_list = NULL,
927 .flags = FLAG_ADVANCED
930 .label = "display charset",
931 .type = P_STRING,
932 .p_class = P_GLOBAL,
933 .ptr = &Globals.display_charset,
934 .special = handle_charset,
935 .enum_list = NULL,
936 .flags = FLAG_ADVANCED
939 .label = "comment",
940 .type = P_STRING,
941 .p_class = P_LOCAL,
942 .ptr = &sDefault.comment,
943 .special = NULL,
944 .enum_list = NULL,
945 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
948 .label = "path",
949 .type = P_STRING,
950 .p_class = P_LOCAL,
951 .ptr = &sDefault.szPath,
952 .special = NULL,
953 .enum_list = NULL,
954 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
957 .label = "directory",
958 .type = P_STRING,
959 .p_class = P_LOCAL,
960 .ptr = &sDefault.szPath,
961 .special = NULL,
962 .enum_list = NULL,
963 .flags = FLAG_HIDE,
966 .label = "workgroup",
967 .type = P_USTRING,
968 .p_class = P_GLOBAL,
969 .ptr = &Globals.szWorkgroup,
970 .special = handle_workgroup,
971 .enum_list = NULL,
972 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
974 #ifdef WITH_ADS
976 .label = "realm",
977 .type = P_USTRING,
978 .p_class = P_GLOBAL,
979 .ptr = &Globals.szRealm,
980 .special = NULL,
981 .enum_list = NULL,
982 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
984 #endif
986 .label = "netbios name",
987 .type = P_USTRING,
988 .p_class = P_GLOBAL,
989 .ptr = &Globals.szNetbiosName,
990 .special = handle_netbios_name,
991 .enum_list = NULL,
992 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
995 .label = "netbios aliases",
996 .type = P_LIST,
997 .p_class = P_GLOBAL,
998 .ptr = &Globals.szNetbiosAliases,
999 .special = handle_netbios_aliases,
1000 .enum_list = NULL,
1001 .flags = FLAG_ADVANCED,
1004 .label = "netbios scope",
1005 .type = P_USTRING,
1006 .p_class = P_GLOBAL,
1007 .ptr = &Globals.szNetbiosScope,
1008 .special = handle_netbios_scope,
1009 .enum_list = NULL,
1010 .flags = FLAG_ADVANCED,
1013 .label = "server string",
1014 .type = P_STRING,
1015 .p_class = P_GLOBAL,
1016 .ptr = &Globals.szServerString,
1017 .special = NULL,
1018 .enum_list = NULL,
1019 .flags = FLAG_BASIC | FLAG_ADVANCED,
1022 .label = "interfaces",
1023 .type = P_LIST,
1024 .p_class = P_GLOBAL,
1025 .ptr = &Globals.szInterfaces,
1026 .special = NULL,
1027 .enum_list = NULL,
1028 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1031 .label = "bind interfaces only",
1032 .type = P_BOOL,
1033 .p_class = P_GLOBAL,
1034 .ptr = &Globals.bBindInterfacesOnly,
1035 .special = NULL,
1036 .enum_list = NULL,
1037 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1040 .label = "config backend",
1041 .type = P_ENUM,
1042 .p_class = P_GLOBAL,
1043 .ptr = &Globals.ConfigBackend,
1044 .special = NULL,
1045 .enum_list = enum_config_backend,
1046 .flags = FLAG_HIDE|FLAG_ADVANCED|FLAG_META,
1049 {N_("Security Options"), P_SEP, P_SEPARATOR},
1052 .label = "security",
1053 .type = P_ENUM,
1054 .p_class = P_GLOBAL,
1055 .ptr = &Globals.security,
1056 .special = NULL,
1057 .enum_list = enum_security,
1058 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1061 .label = "auth methods",
1062 .type = P_LIST,
1063 .p_class = P_GLOBAL,
1064 .ptr = &Globals.AuthMethods,
1065 .special = NULL,
1066 .enum_list = NULL,
1067 .flags = FLAG_ADVANCED,
1070 .label = "encrypt passwords",
1071 .type = P_BOOL,
1072 .p_class = P_GLOBAL,
1073 .ptr = &Globals.bEncryptPasswords,
1074 .special = NULL,
1075 .enum_list = NULL,
1076 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1079 .label = "update encrypted",
1080 .type = P_BOOL,
1081 .p_class = P_GLOBAL,
1082 .ptr = &Globals.bUpdateEncrypt,
1083 .special = NULL,
1084 .enum_list = NULL,
1085 .flags = FLAG_ADVANCED,
1088 .label = "client schannel",
1089 .type = P_ENUM,
1090 .p_class = P_GLOBAL,
1091 .ptr = &Globals.clientSchannel,
1092 .special = NULL,
1093 .enum_list = enum_bool_auto,
1094 .flags = FLAG_BASIC | FLAG_ADVANCED,
1097 .label = "server schannel",
1098 .type = P_ENUM,
1099 .p_class = P_GLOBAL,
1100 .ptr = &Globals.serverSchannel,
1101 .special = NULL,
1102 .enum_list = enum_bool_auto,
1103 .flags = FLAG_BASIC | FLAG_ADVANCED,
1106 .label = "allow trusted domains",
1107 .type = P_BOOL,
1108 .p_class = P_GLOBAL,
1109 .ptr = &Globals.bAllowTrustedDomains,
1110 .special = NULL,
1111 .enum_list = NULL,
1112 .flags = FLAG_ADVANCED,
1115 .label = "map to guest",
1116 .type = P_ENUM,
1117 .p_class = P_GLOBAL,
1118 .ptr = &Globals.map_to_guest,
1119 .special = NULL,
1120 .enum_list = enum_map_to_guest,
1121 .flags = FLAG_ADVANCED,
1124 .label = "null passwords",
1125 .type = P_BOOL,
1126 .p_class = P_GLOBAL,
1127 .ptr = &Globals.bNullPasswords,
1128 .special = NULL,
1129 .enum_list = NULL,
1130 .flags = FLAG_ADVANCED,
1133 .label = "obey pam restrictions",
1134 .type = P_BOOL,
1135 .p_class = P_GLOBAL,
1136 .ptr = &Globals.bObeyPamRestrictions,
1137 .special = NULL,
1138 .enum_list = NULL,
1139 .flags = FLAG_ADVANCED,
1142 .label = "password server",
1143 .type = P_STRING,
1144 .p_class = P_GLOBAL,
1145 .ptr = &Globals.szPasswordServer,
1146 .special = NULL,
1147 .enum_list = NULL,
1148 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1151 .label = "smb passwd file",
1152 .type = P_STRING,
1153 .p_class = P_GLOBAL,
1154 .ptr = &Globals.szSMBPasswdFile,
1155 .special = NULL,
1156 .enum_list = NULL,
1157 .flags = FLAG_ADVANCED,
1160 .label = "private dir",
1161 .type = P_STRING,
1162 .p_class = P_GLOBAL,
1163 .ptr = &Globals.szPrivateDir,
1164 .special = NULL,
1165 .enum_list = NULL,
1166 .flags = FLAG_ADVANCED,
1169 .label = "passdb backend",
1170 .type = P_STRING,
1171 .p_class = P_GLOBAL,
1172 .ptr = &Globals.szPassdbBackend,
1173 .special = NULL,
1174 .enum_list = NULL,
1175 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1178 .label = "algorithmic rid base",
1179 .type = P_INTEGER,
1180 .p_class = P_GLOBAL,
1181 .ptr = &Globals.AlgorithmicRidBase,
1182 .special = NULL,
1183 .enum_list = NULL,
1184 .flags = FLAG_ADVANCED,
1187 .label = "root directory",
1188 .type = P_STRING,
1189 .p_class = P_GLOBAL,
1190 .ptr = &Globals.szRootdir,
1191 .special = NULL,
1192 .enum_list = NULL,
1193 .flags = FLAG_ADVANCED,
1196 .label = "root dir",
1197 .type = P_STRING,
1198 .p_class = P_GLOBAL,
1199 .ptr = &Globals.szRootdir,
1200 .special = NULL,
1201 .enum_list = NULL,
1202 .flags = FLAG_HIDE,
1205 .label = "root",
1206 .type = P_STRING,
1207 .p_class = P_GLOBAL,
1208 .ptr = &Globals.szRootdir,
1209 .special = NULL,
1210 .enum_list = NULL,
1211 .flags = FLAG_HIDE,
1214 .label = "guest account",
1215 .type = P_STRING,
1216 .p_class = P_GLOBAL,
1217 .ptr = &Globals.szGuestaccount,
1218 .special = NULL,
1219 .enum_list = NULL,
1220 .flags = FLAG_BASIC | FLAG_ADVANCED,
1223 .label = "enable privileges",
1224 .type = P_BOOL,
1225 .p_class = P_GLOBAL,
1226 .ptr = &Globals.bEnablePrivileges,
1227 .special = NULL,
1228 .enum_list = NULL,
1229 .flags = FLAG_ADVANCED,
1233 .label = "pam password change",
1234 .type = P_BOOL,
1235 .p_class = P_GLOBAL,
1236 .ptr = &Globals.bPamPasswordChange,
1237 .special = NULL,
1238 .enum_list = NULL,
1239 .flags = FLAG_ADVANCED,
1242 .label = "passwd program",
1243 .type = P_STRING,
1244 .p_class = P_GLOBAL,
1245 .ptr = &Globals.szPasswdProgram,
1246 .special = NULL,
1247 .enum_list = NULL,
1248 .flags = FLAG_ADVANCED,
1251 .label = "passwd chat",
1252 .type = P_STRING,
1253 .p_class = P_GLOBAL,
1254 .ptr = &Globals.szPasswdChat,
1255 .special = NULL,
1256 .enum_list = NULL,
1257 .flags = FLAG_ADVANCED,
1260 .label = "passwd chat debug",
1261 .type = P_BOOL,
1262 .p_class = P_GLOBAL,
1263 .ptr = &Globals.bPasswdChatDebug,
1264 .special = NULL,
1265 .enum_list = NULL,
1266 .flags = FLAG_ADVANCED,
1269 .label = "passwd chat timeout",
1270 .type = P_INTEGER,
1271 .p_class = P_GLOBAL,
1272 .ptr = &Globals.iPasswdChatTimeout,
1273 .special = NULL,
1274 .enum_list = NULL,
1275 .flags = FLAG_ADVANCED,
1278 .label = "check password script",
1279 .type = P_STRING,
1280 .p_class = P_GLOBAL,
1281 .ptr = &Globals.szCheckPasswordScript,
1282 .special = NULL,
1283 .enum_list = NULL,
1284 .flags = FLAG_ADVANCED,
1287 .label = "username map",
1288 .type = P_STRING,
1289 .p_class = P_GLOBAL,
1290 .ptr = &Globals.szUsernameMap,
1291 .special = NULL,
1292 .enum_list = NULL,
1293 .flags = FLAG_ADVANCED,
1296 .label = "password level",
1297 .type = P_INTEGER,
1298 .p_class = P_GLOBAL,
1299 .ptr = &Globals.pwordlevel,
1300 .special = NULL,
1301 .enum_list = NULL,
1302 .flags = FLAG_ADVANCED,
1305 .label = "username level",
1306 .type = P_INTEGER,
1307 .p_class = P_GLOBAL,
1308 .ptr = &Globals.unamelevel,
1309 .special = NULL,
1310 .enum_list = NULL,
1311 .flags = FLAG_ADVANCED,
1314 .label = "unix password sync",
1315 .type = P_BOOL,
1316 .p_class = P_GLOBAL,
1317 .ptr = &Globals.bUnixPasswdSync,
1318 .special = NULL,
1319 .enum_list = NULL,
1320 .flags = FLAG_ADVANCED,
1323 .label = "restrict anonymous",
1324 .type = P_INTEGER,
1325 .p_class = P_GLOBAL,
1326 .ptr = &Globals.restrict_anonymous,
1327 .special = NULL,
1328 .enum_list = NULL,
1329 .flags = FLAG_ADVANCED,
1332 .label = "lanman auth",
1333 .type = P_BOOL,
1334 .p_class = P_GLOBAL,
1335 .ptr = &Globals.bLanmanAuth,
1336 .special = NULL,
1337 .enum_list = NULL,
1338 .flags = FLAG_ADVANCED,
1341 .label = "ntlm auth",
1342 .type = P_BOOL,
1343 .p_class = P_GLOBAL,
1344 .ptr = &Globals.bNTLMAuth,
1345 .special = NULL,
1346 .enum_list = NULL,
1347 .flags = FLAG_ADVANCED,
1350 .label = "client NTLMv2 auth",
1351 .type = P_BOOL,
1352 .p_class = P_GLOBAL,
1353 .ptr = &Globals.bClientNTLMv2Auth,
1354 .special = NULL,
1355 .enum_list = NULL,
1356 .flags = FLAG_ADVANCED,
1359 .label = "client lanman auth",
1360 .type = P_BOOL,
1361 .p_class = P_GLOBAL,
1362 .ptr = &Globals.bClientLanManAuth,
1363 .special = NULL,
1364 .enum_list = NULL,
1365 .flags = FLAG_ADVANCED,
1368 .label = "client plaintext auth",
1369 .type = P_BOOL,
1370 .p_class = P_GLOBAL,
1371 .ptr = &Globals.bClientPlaintextAuth,
1372 .special = NULL,
1373 .enum_list = NULL,
1374 .flags = FLAG_ADVANCED,
1377 .label = "username",
1378 .type = P_STRING,
1379 .p_class = P_LOCAL,
1380 .ptr = &sDefault.szUsername,
1381 .special = NULL,
1382 .enum_list = NULL,
1383 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1386 .label = "user",
1387 .type = P_STRING,
1388 .p_class = P_LOCAL,
1389 .ptr = &sDefault.szUsername,
1390 .special = NULL,
1391 .enum_list = NULL,
1392 .flags = FLAG_HIDE,
1395 .label = "users",
1396 .type = P_STRING,
1397 .p_class = P_LOCAL,
1398 .ptr = &sDefault.szUsername,
1399 .special = NULL,
1400 .enum_list = NULL,
1401 .flags = FLAG_HIDE,
1404 .label = "invalid users",
1405 .type = P_LIST,
1406 .p_class = P_LOCAL,
1407 .ptr = &sDefault.szInvalidUsers,
1408 .special = NULL,
1409 .enum_list = NULL,
1410 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1413 .label = "valid users",
1414 .type = P_LIST,
1415 .p_class = P_LOCAL,
1416 .ptr = &sDefault.szValidUsers,
1417 .special = NULL,
1418 .enum_list = NULL,
1419 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1422 .label = "admin users",
1423 .type = P_LIST,
1424 .p_class = P_LOCAL,
1425 .ptr = &sDefault.szAdminUsers,
1426 .special = NULL,
1427 .enum_list = NULL,
1428 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1431 .label = "read list",
1432 .type = P_LIST,
1433 .p_class = P_LOCAL,
1434 .ptr = &sDefault.readlist,
1435 .special = NULL,
1436 .enum_list = NULL,
1437 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1440 .label = "write list",
1441 .type = P_LIST,
1442 .p_class = P_LOCAL,
1443 .ptr = &sDefault.writelist,
1444 .special = NULL,
1445 .enum_list = NULL,
1446 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1449 .label = "printer admin",
1450 .type = P_LIST,
1451 .p_class = P_LOCAL,
1452 .ptr = &sDefault.printer_admin,
1453 .special = NULL,
1454 .enum_list = NULL,
1455 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1458 .label = "force user",
1459 .type = P_STRING,
1460 .p_class = P_LOCAL,
1461 .ptr = &sDefault.force_user,
1462 .special = NULL,
1463 .enum_list = NULL,
1464 .flags = FLAG_ADVANCED | FLAG_SHARE,
1467 .label = "force group",
1468 .type = P_STRING,
1469 .p_class = P_LOCAL,
1470 .ptr = &sDefault.force_group,
1471 .special = NULL,
1472 .enum_list = NULL,
1473 .flags = FLAG_ADVANCED | FLAG_SHARE,
1476 .label = "group",
1477 .type = P_STRING,
1478 .p_class = P_LOCAL,
1479 .ptr = &sDefault.force_group,
1480 .special = NULL,
1481 .enum_list = NULL,
1482 .flags = FLAG_ADVANCED,
1485 .label = "read only",
1486 .type = P_BOOL,
1487 .p_class = P_LOCAL,
1488 .ptr = &sDefault.bRead_only,
1489 .special = NULL,
1490 .enum_list = NULL,
1491 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1494 .label = "write ok",
1495 .type = P_BOOLREV,
1496 .p_class = P_LOCAL,
1497 .ptr = &sDefault.bRead_only,
1498 .special = NULL,
1499 .enum_list = NULL,
1500 .flags = FLAG_HIDE,
1503 .label = "writeable",
1504 .type = P_BOOLREV,
1505 .p_class = P_LOCAL,
1506 .ptr = &sDefault.bRead_only,
1507 .special = NULL,
1508 .enum_list = NULL,
1509 .flags = FLAG_HIDE,
1512 .label = "writable",
1513 .type = P_BOOLREV,
1514 .p_class = P_LOCAL,
1515 .ptr = &sDefault.bRead_only,
1516 .special = NULL,
1517 .enum_list = NULL,
1518 .flags = FLAG_HIDE,
1521 .label = "acl check permissions",
1522 .type = P_BOOL,
1523 .p_class = P_LOCAL,
1524 .ptr = &sDefault.bAclCheckPermissions,
1525 .special = NULL,
1526 .enum_list = NULL,
1527 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1530 .label = "acl group control",
1531 .type = P_BOOL,
1532 .p_class = P_LOCAL,
1533 .ptr = &sDefault.bAclGroupControl,
1534 .special = NULL,
1535 .enum_list = NULL,
1536 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1539 .label = "acl map full control",
1540 .type = P_BOOL,
1541 .p_class = P_LOCAL,
1542 .ptr = &sDefault.bAclMapFullControl,
1543 .special = NULL,
1544 .enum_list = NULL,
1545 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1548 .label = "create mask",
1549 .type = P_OCTAL,
1550 .p_class = P_LOCAL,
1551 .ptr = &sDefault.iCreate_mask,
1552 .special = NULL,
1553 .enum_list = NULL,
1554 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1557 .label = "create mode",
1558 .type = P_OCTAL,
1559 .p_class = P_LOCAL,
1560 .ptr = &sDefault.iCreate_mask,
1561 .special = NULL,
1562 .enum_list = NULL,
1563 .flags = FLAG_HIDE,
1566 .label = "force create mode",
1567 .type = P_OCTAL,
1568 .p_class = P_LOCAL,
1569 .ptr = &sDefault.iCreate_force_mode,
1570 .special = NULL,
1571 .enum_list = NULL,
1572 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1575 .label = "security mask",
1576 .type = P_OCTAL,
1577 .p_class = P_LOCAL,
1578 .ptr = &sDefault.iSecurity_mask,
1579 .special = NULL,
1580 .enum_list = NULL,
1581 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1584 .label = "force security mode",
1585 .type = P_OCTAL,
1586 .p_class = P_LOCAL,
1587 .ptr = &sDefault.iSecurity_force_mode,
1588 .special = NULL,
1589 .enum_list = NULL,
1590 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1593 .label = "directory mask",
1594 .type = P_OCTAL,
1595 .p_class = P_LOCAL,
1596 .ptr = &sDefault.iDir_mask,
1597 .special = NULL,
1598 .enum_list = NULL,
1599 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1602 .label = "directory mode",
1603 .type = P_OCTAL,
1604 .p_class = P_LOCAL,
1605 .ptr = &sDefault.iDir_mask,
1606 .special = NULL,
1607 .enum_list = NULL,
1608 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1611 .label = "force directory mode",
1612 .type = P_OCTAL,
1613 .p_class = P_LOCAL,
1614 .ptr = &sDefault.iDir_force_mode,
1615 .special = NULL,
1616 .enum_list = NULL,
1617 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1620 .label = "directory security mask",
1621 .type = P_OCTAL,
1622 .p_class = P_LOCAL,
1623 .ptr = &sDefault.iDir_Security_mask,
1624 .special = NULL,
1625 .enum_list = NULL,
1626 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1629 .label = "force directory security mode",
1630 .type = P_OCTAL,
1631 .p_class = P_LOCAL,
1632 .ptr = &sDefault.iDir_Security_force_mode,
1633 .special = NULL,
1634 .enum_list = NULL,
1635 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1638 .label = "force unknown acl user",
1639 .type = P_BOOL,
1640 .p_class = P_LOCAL,
1641 .ptr = &sDefault.bForceUnknownAclUser,
1642 .special = NULL,
1643 .enum_list = NULL,
1644 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1647 .label = "inherit permissions",
1648 .type = P_BOOL,
1649 .p_class = P_LOCAL,
1650 .ptr = &sDefault.bInheritPerms,
1651 .special = NULL,
1652 .enum_list = NULL,
1653 .flags = FLAG_ADVANCED | FLAG_SHARE,
1656 .label = "inherit acls",
1657 .type = P_BOOL,
1658 .p_class = P_LOCAL,
1659 .ptr = &sDefault.bInheritACLS,
1660 .special = NULL,
1661 .enum_list = NULL,
1662 .flags = FLAG_ADVANCED | FLAG_SHARE,
1665 .label = "inherit owner",
1666 .type = P_BOOL,
1667 .p_class = P_LOCAL,
1668 .ptr = &sDefault.bInheritOwner,
1669 .special = NULL,
1670 .enum_list = NULL,
1671 .flags = FLAG_ADVANCED | FLAG_SHARE,
1674 .label = "guest only",
1675 .type = P_BOOL,
1676 .p_class = P_LOCAL,
1677 .ptr = &sDefault.bGuest_only,
1678 .special = NULL,
1679 .enum_list = NULL,
1680 .flags = FLAG_ADVANCED | FLAG_SHARE,
1683 .label = "only guest",
1684 .type = P_BOOL,
1685 .p_class = P_LOCAL,
1686 .ptr = &sDefault.bGuest_only,
1687 .special = NULL,
1688 .enum_list = NULL,
1689 .flags = FLAG_HIDE,
1692 .label = "administrative share",
1693 .type = P_BOOL,
1694 .p_class = P_LOCAL,
1695 .ptr = &sDefault.bAdministrative_share,
1696 .special = NULL,
1697 .enum_list = NULL,
1698 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1702 .label = "guest ok",
1703 .type = P_BOOL,
1704 .p_class = P_LOCAL,
1705 .ptr = &sDefault.bGuest_ok,
1706 .special = NULL,
1707 .enum_list = NULL,
1708 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1711 .label = "public",
1712 .type = P_BOOL,
1713 .p_class = P_LOCAL,
1714 .ptr = &sDefault.bGuest_ok,
1715 .special = NULL,
1716 .enum_list = NULL,
1717 .flags = FLAG_HIDE,
1720 .label = "only user",
1721 .type = P_BOOL,
1722 .p_class = P_LOCAL,
1723 .ptr = &sDefault.bOnlyUser,
1724 .special = NULL,
1725 .enum_list = NULL,
1726 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1729 .label = "hosts allow",
1730 .type = P_LIST,
1731 .p_class = P_LOCAL,
1732 .ptr = &sDefault.szHostsallow,
1733 .special = NULL,
1734 .enum_list = NULL,
1735 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1738 .label = "allow hosts",
1739 .type = P_LIST,
1740 .p_class = P_LOCAL,
1741 .ptr = &sDefault.szHostsallow,
1742 .special = NULL,
1743 .enum_list = NULL,
1744 .flags = FLAG_HIDE,
1747 .label = "hosts deny",
1748 .type = P_LIST,
1749 .p_class = P_LOCAL,
1750 .ptr = &sDefault.szHostsdeny,
1751 .special = NULL,
1752 .enum_list = NULL,
1753 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1756 .label = "deny hosts",
1757 .type = P_LIST,
1758 .p_class = P_LOCAL,
1759 .ptr = &sDefault.szHostsdeny,
1760 .special = NULL,
1761 .enum_list = NULL,
1762 .flags = FLAG_HIDE,
1765 .label = "preload modules",
1766 .type = P_LIST,
1767 .p_class = P_GLOBAL,
1768 .ptr = &Globals.szPreloadModules,
1769 .special = NULL,
1770 .enum_list = NULL,
1771 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1774 .label = "dedicated keytab file",
1775 .type = P_STRING,
1776 .p_class = P_GLOBAL,
1777 .ptr = &Globals.szDedicatedKeytabFile,
1778 .special = NULL,
1779 .enum_list = NULL,
1780 .flags = FLAG_ADVANCED,
1783 .label = "kerberos method",
1784 .type = P_ENUM,
1785 .p_class = P_GLOBAL,
1786 .ptr = &Globals.iKerberosMethod,
1787 .special = NULL,
1788 .enum_list = enum_kerberos_method,
1789 .flags = FLAG_ADVANCED,
1792 .label = "map untrusted to domain",
1793 .type = P_BOOL,
1794 .p_class = P_GLOBAL,
1795 .ptr = &Globals.bMapUntrustedToDomain,
1796 .special = NULL,
1797 .enum_list = NULL,
1798 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1802 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1805 .label = "log level",
1806 .type = P_STRING,
1807 .p_class = P_GLOBAL,
1808 .ptr = &Globals.szLogLevel,
1809 .special = handle_debug_list,
1810 .enum_list = NULL,
1811 .flags = FLAG_ADVANCED,
1814 .label = "debuglevel",
1815 .type = P_STRING,
1816 .p_class = P_GLOBAL,
1817 .ptr = &Globals.szLogLevel,
1818 .special = handle_debug_list,
1819 .enum_list = NULL,
1820 .flags = FLAG_HIDE,
1823 .label = "syslog",
1824 .type = P_INTEGER,
1825 .p_class = P_GLOBAL,
1826 .ptr = &Globals.syslog,
1827 .special = NULL,
1828 .enum_list = NULL,
1829 .flags = FLAG_ADVANCED,
1832 .label = "syslog only",
1833 .type = P_BOOL,
1834 .p_class = P_GLOBAL,
1835 .ptr = &Globals.bSyslogOnly,
1836 .special = NULL,
1837 .enum_list = NULL,
1838 .flags = FLAG_ADVANCED,
1841 .label = "log file",
1842 .type = P_STRING,
1843 .p_class = P_GLOBAL,
1844 .ptr = &Globals.szLogFile,
1845 .special = NULL,
1846 .enum_list = NULL,
1847 .flags = FLAG_ADVANCED,
1850 .label = "max log size",
1851 .type = P_INTEGER,
1852 .p_class = P_GLOBAL,
1853 .ptr = &Globals.max_log_size,
1854 .special = NULL,
1855 .enum_list = NULL,
1856 .flags = FLAG_ADVANCED,
1859 .label = "debug timestamp",
1860 .type = P_BOOL,
1861 .p_class = P_GLOBAL,
1862 .ptr = &Globals.bTimestampLogs,
1863 .special = NULL,
1864 .enum_list = NULL,
1865 .flags = FLAG_ADVANCED,
1868 .label = "timestamp logs",
1869 .type = P_BOOL,
1870 .p_class = P_GLOBAL,
1871 .ptr = &Globals.bTimestampLogs,
1872 .special = NULL,
1873 .enum_list = NULL,
1874 .flags = FLAG_ADVANCED,
1877 .label = "debug prefix timestamp",
1878 .type = P_BOOL,
1879 .p_class = P_GLOBAL,
1880 .ptr = &Globals.bDebugPrefixTimestamp,
1881 .special = NULL,
1882 .enum_list = NULL,
1883 .flags = FLAG_ADVANCED,
1886 .label = "debug hires timestamp",
1887 .type = P_BOOL,
1888 .p_class = P_GLOBAL,
1889 .ptr = &Globals.bDebugHiresTimestamp,
1890 .special = NULL,
1891 .enum_list = NULL,
1892 .flags = FLAG_ADVANCED,
1895 .label = "debug pid",
1896 .type = P_BOOL,
1897 .p_class = P_GLOBAL,
1898 .ptr = &Globals.bDebugPid,
1899 .special = NULL,
1900 .enum_list = NULL,
1901 .flags = FLAG_ADVANCED,
1904 .label = "debug uid",
1905 .type = P_BOOL,
1906 .p_class = P_GLOBAL,
1907 .ptr = &Globals.bDebugUid,
1908 .special = NULL,
1909 .enum_list = NULL,
1910 .flags = FLAG_ADVANCED,
1913 .label = "debug class",
1914 .type = P_BOOL,
1915 .p_class = P_GLOBAL,
1916 .ptr = &Globals.bDebugClass,
1917 .special = NULL,
1918 .enum_list = NULL,
1919 .flags = FLAG_ADVANCED,
1922 .label = "enable core files",
1923 .type = P_BOOL,
1924 .p_class = P_GLOBAL,
1925 .ptr = &Globals.bEnableCoreFiles,
1926 .special = NULL,
1927 .enum_list = NULL,
1928 .flags = FLAG_ADVANCED,
1931 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1934 .label = "allocation roundup size",
1935 .type = P_INTEGER,
1936 .p_class = P_LOCAL,
1937 .ptr = &sDefault.iallocation_roundup_size,
1938 .special = NULL,
1939 .enum_list = NULL,
1940 .flags = FLAG_ADVANCED,
1943 .label = "aio read size",
1944 .type = P_INTEGER,
1945 .p_class = P_LOCAL,
1946 .ptr = &sDefault.iAioReadSize,
1947 .special = NULL,
1948 .enum_list = NULL,
1949 .flags = FLAG_ADVANCED,
1952 .label = "aio write size",
1953 .type = P_INTEGER,
1954 .p_class = P_LOCAL,
1955 .ptr = &sDefault.iAioWriteSize,
1956 .special = NULL,
1957 .enum_list = NULL,
1958 .flags = FLAG_ADVANCED,
1961 .label = "aio write behind",
1962 .type = P_STRING,
1963 .p_class = P_LOCAL,
1964 .ptr = &sDefault.szAioWriteBehind,
1965 .special = NULL,
1966 .enum_list = NULL,
1967 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1970 .label = "smb ports",
1971 .type = P_STRING,
1972 .p_class = P_GLOBAL,
1973 .ptr = &Globals.smb_ports,
1974 .special = NULL,
1975 .enum_list = NULL,
1976 .flags = FLAG_ADVANCED,
1979 .label = "large readwrite",
1980 .type = P_BOOL,
1981 .p_class = P_GLOBAL,
1982 .ptr = &Globals.bLargeReadwrite,
1983 .special = NULL,
1984 .enum_list = NULL,
1985 .flags = FLAG_ADVANCED,
1988 .label = "max protocol",
1989 .type = P_ENUM,
1990 .p_class = P_GLOBAL,
1991 .ptr = &Globals.maxprotocol,
1992 .special = NULL,
1993 .enum_list = enum_protocol,
1994 .flags = FLAG_ADVANCED,
1997 .label = "protocol",
1998 .type = P_ENUM,
1999 .p_class = P_GLOBAL,
2000 .ptr = &Globals.maxprotocol,
2001 .special = NULL,
2002 .enum_list = enum_protocol,
2003 .flags = FLAG_ADVANCED,
2006 .label = "min protocol",
2007 .type = P_ENUM,
2008 .p_class = P_GLOBAL,
2009 .ptr = &Globals.minprotocol,
2010 .special = NULL,
2011 .enum_list = enum_protocol,
2012 .flags = FLAG_ADVANCED,
2015 .label = "min receivefile size",
2016 .type = P_INTEGER,
2017 .p_class = P_GLOBAL,
2018 .ptr = &Globals.iminreceivefile,
2019 .special = NULL,
2020 .enum_list = NULL,
2021 .flags = FLAG_ADVANCED,
2024 .label = "read raw",
2025 .type = P_BOOL,
2026 .p_class = P_GLOBAL,
2027 .ptr = &Globals.bReadRaw,
2028 .special = NULL,
2029 .enum_list = NULL,
2030 .flags = FLAG_ADVANCED,
2033 .label = "write raw",
2034 .type = P_BOOL,
2035 .p_class = P_GLOBAL,
2036 .ptr = &Globals.bWriteRaw,
2037 .special = NULL,
2038 .enum_list = NULL,
2039 .flags = FLAG_ADVANCED,
2042 .label = "disable netbios",
2043 .type = P_BOOL,
2044 .p_class = P_GLOBAL,
2045 .ptr = &Globals.bDisableNetbios,
2046 .special = NULL,
2047 .enum_list = NULL,
2048 .flags = FLAG_ADVANCED,
2051 .label = "reset on zero vc",
2052 .type = P_BOOL,
2053 .p_class = P_GLOBAL,
2054 .ptr = &Globals.bResetOnZeroVC,
2055 .special = NULL,
2056 .enum_list = NULL,
2057 .flags = FLAG_ADVANCED,
2060 .label = "acl compatibility",
2061 .type = P_ENUM,
2062 .p_class = P_GLOBAL,
2063 .ptr = &Globals.iAclCompat,
2064 .special = NULL,
2065 .enum_list = enum_acl_compat_vals,
2066 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2069 .label = "defer sharing violations",
2070 .type = P_BOOL,
2071 .p_class = P_GLOBAL,
2072 .ptr = &Globals.bDeferSharingViolations,
2073 .special = NULL,
2074 .enum_list = NULL,
2075 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2078 .label = "ea support",
2079 .type = P_BOOL,
2080 .p_class = P_LOCAL,
2081 .ptr = &sDefault.bEASupport,
2082 .special = NULL,
2083 .enum_list = NULL,
2084 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2087 .label = "nt acl support",
2088 .type = P_BOOL,
2089 .p_class = P_LOCAL,
2090 .ptr = &sDefault.bNTAclSupport,
2091 .special = NULL,
2092 .enum_list = NULL,
2093 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2096 .label = "nt pipe support",
2097 .type = P_BOOL,
2098 .p_class = P_GLOBAL,
2099 .ptr = &Globals.bNTPipeSupport,
2100 .special = NULL,
2101 .enum_list = NULL,
2102 .flags = FLAG_ADVANCED,
2105 .label = "nt status support",
2106 .type = P_BOOL,
2107 .p_class = P_GLOBAL,
2108 .ptr = &Globals.bNTStatusSupport,
2109 .special = NULL,
2110 .enum_list = NULL,
2111 .flags = FLAG_ADVANCED,
2114 .label = "profile acls",
2115 .type = P_BOOL,
2116 .p_class = P_LOCAL,
2117 .ptr = &sDefault.bProfileAcls,
2118 .special = NULL,
2119 .enum_list = NULL,
2120 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2123 .label = "announce version",
2124 .type = P_STRING,
2125 .p_class = P_GLOBAL,
2126 .ptr = &Globals.szAnnounceVersion,
2127 .special = NULL,
2128 .enum_list = NULL,
2129 .flags = FLAG_ADVANCED,
2132 .label = "announce as",
2133 .type = P_ENUM,
2134 .p_class = P_GLOBAL,
2135 .ptr = &Globals.announce_as,
2136 .special = NULL,
2137 .enum_list = enum_announce_as,
2138 .flags = FLAG_ADVANCED,
2141 .label = "map acl inherit",
2142 .type = P_BOOL,
2143 .p_class = P_LOCAL,
2144 .ptr = &sDefault.bMap_acl_inherit,
2145 .special = NULL,
2146 .enum_list = NULL,
2147 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2150 .label = "afs share",
2151 .type = P_BOOL,
2152 .p_class = P_LOCAL,
2153 .ptr = &sDefault.bAfs_Share,
2154 .special = NULL,
2155 .enum_list = NULL,
2156 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2159 .label = "max mux",
2160 .type = P_INTEGER,
2161 .p_class = P_GLOBAL,
2162 .ptr = &Globals.max_mux,
2163 .special = NULL,
2164 .enum_list = NULL,
2165 .flags = FLAG_ADVANCED,
2168 .label = "max xmit",
2169 .type = P_INTEGER,
2170 .p_class = P_GLOBAL,
2171 .ptr = &Globals.max_xmit,
2172 .special = NULL,
2173 .enum_list = NULL,
2174 .flags = FLAG_ADVANCED,
2177 .label = "name resolve order",
2178 .type = P_STRING,
2179 .p_class = P_GLOBAL,
2180 .ptr = &Globals.szNameResolveOrder,
2181 .special = NULL,
2182 .enum_list = NULL,
2183 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2186 .label = "max ttl",
2187 .type = P_INTEGER,
2188 .p_class = P_GLOBAL,
2189 .ptr = &Globals.max_ttl,
2190 .special = NULL,
2191 .enum_list = NULL,
2192 .flags = FLAG_ADVANCED,
2195 .label = "max wins ttl",
2196 .type = P_INTEGER,
2197 .p_class = P_GLOBAL,
2198 .ptr = &Globals.max_wins_ttl,
2199 .special = NULL,
2200 .enum_list = NULL,
2201 .flags = FLAG_ADVANCED,
2204 .label = "min wins ttl",
2205 .type = P_INTEGER,
2206 .p_class = P_GLOBAL,
2207 .ptr = &Globals.min_wins_ttl,
2208 .special = NULL,
2209 .enum_list = NULL,
2210 .flags = FLAG_ADVANCED,
2213 .label = "time server",
2214 .type = P_BOOL,
2215 .p_class = P_GLOBAL,
2216 .ptr = &Globals.bTimeServer,
2217 .special = NULL,
2218 .enum_list = NULL,
2219 .flags = FLAG_ADVANCED,
2222 .label = "unix extensions",
2223 .type = P_BOOL,
2224 .p_class = P_GLOBAL,
2225 .ptr = &Globals.bUnixExtensions,
2226 .special = NULL,
2227 .enum_list = NULL,
2228 .flags = FLAG_ADVANCED,
2231 .label = "use spnego",
2232 .type = P_BOOL,
2233 .p_class = P_GLOBAL,
2234 .ptr = &Globals.bUseSpnego,
2235 .special = NULL,
2236 .enum_list = NULL,
2237 .flags = FLAG_ADVANCED,
2240 .label = "client signing",
2241 .type = P_ENUM,
2242 .p_class = P_GLOBAL,
2243 .ptr = &Globals.client_signing,
2244 .special = NULL,
2245 .enum_list = enum_smb_signing_vals,
2246 .flags = FLAG_ADVANCED,
2249 .label = "server signing",
2250 .type = P_ENUM,
2251 .p_class = P_GLOBAL,
2252 .ptr = &Globals.server_signing,
2253 .special = NULL,
2254 .enum_list = enum_smb_signing_vals,
2255 .flags = FLAG_ADVANCED,
2258 .label = "smb encrypt",
2259 .type = P_ENUM,
2260 .p_class = P_LOCAL,
2261 .ptr = &sDefault.ismb_encrypt,
2262 .special = NULL,
2263 .enum_list = enum_smb_signing_vals,
2264 .flags = FLAG_ADVANCED,
2267 .label = "client use spnego",
2268 .type = P_BOOL,
2269 .p_class = P_GLOBAL,
2270 .ptr = &Globals.bClientUseSpnego,
2271 .special = NULL,
2272 .enum_list = NULL,
2273 .flags = FLAG_ADVANCED,
2276 .label = "client ldap sasl wrapping",
2277 .type = P_ENUM,
2278 .p_class = P_GLOBAL,
2279 .ptr = &Globals.client_ldap_sasl_wrapping,
2280 .special = NULL,
2281 .enum_list = enum_ldap_sasl_wrapping,
2282 .flags = FLAG_ADVANCED,
2285 .label = "enable asu support",
2286 .type = P_BOOL,
2287 .p_class = P_GLOBAL,
2288 .ptr = &Globals.bASUSupport,
2289 .special = NULL,
2290 .enum_list = NULL,
2291 .flags = FLAG_ADVANCED,
2294 .label = "svcctl list",
2295 .type = P_LIST,
2296 .p_class = P_GLOBAL,
2297 .ptr = &Globals.szServicesList,
2298 .special = NULL,
2299 .enum_list = NULL,
2300 .flags = FLAG_ADVANCED,
2303 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2306 .label = "block size",
2307 .type = P_INTEGER,
2308 .p_class = P_LOCAL,
2309 .ptr = &sDefault.iBlock_size,
2310 .special = NULL,
2311 .enum_list = NULL,
2312 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2315 .label = "deadtime",
2316 .type = P_INTEGER,
2317 .p_class = P_GLOBAL,
2318 .ptr = &Globals.deadtime,
2319 .special = NULL,
2320 .enum_list = NULL,
2321 .flags = FLAG_ADVANCED,
2324 .label = "getwd cache",
2325 .type = P_BOOL,
2326 .p_class = P_GLOBAL,
2327 .ptr = &Globals.getwd_cache,
2328 .special = NULL,
2329 .enum_list = NULL,
2330 .flags = FLAG_ADVANCED,
2333 .label = "keepalive",
2334 .type = P_INTEGER,
2335 .p_class = P_GLOBAL,
2336 .ptr = &Globals.iKeepalive,
2337 .special = NULL,
2338 .enum_list = NULL,
2339 .flags = FLAG_ADVANCED,
2342 .label = "change notify",
2343 .type = P_BOOL,
2344 .p_class = P_LOCAL,
2345 .ptr = &sDefault.bChangeNotify,
2346 .special = NULL,
2347 .enum_list = NULL,
2348 .flags = FLAG_ADVANCED | FLAG_SHARE,
2351 .label = "directory name cache size",
2352 .type = P_INTEGER,
2353 .p_class = P_LOCAL,
2354 .ptr = &sDefault.iDirectoryNameCacheSize,
2355 .special = NULL,
2356 .enum_list = NULL,
2357 .flags = FLAG_ADVANCED | FLAG_SHARE,
2360 .label = "kernel change notify",
2361 .type = P_BOOL,
2362 .p_class = P_LOCAL,
2363 .ptr = &sDefault.bKernelChangeNotify,
2364 .special = NULL,
2365 .enum_list = NULL,
2366 .flags = FLAG_ADVANCED | FLAG_SHARE,
2369 .label = "lpq cache time",
2370 .type = P_INTEGER,
2371 .p_class = P_GLOBAL,
2372 .ptr = &Globals.lpqcachetime,
2373 .special = NULL,
2374 .enum_list = NULL,
2375 .flags = FLAG_ADVANCED,
2378 .label = "max smbd processes",
2379 .type = P_INTEGER,
2380 .p_class = P_GLOBAL,
2381 .ptr = &Globals.iMaxSmbdProcesses,
2382 .special = NULL,
2383 .enum_list = NULL,
2384 .flags = FLAG_ADVANCED,
2387 .label = "max connections",
2388 .type = P_INTEGER,
2389 .p_class = P_LOCAL,
2390 .ptr = &sDefault.iMaxConnections,
2391 .special = NULL,
2392 .enum_list = NULL,
2393 .flags = FLAG_ADVANCED | FLAG_SHARE,
2396 .label = "paranoid server security",
2397 .type = P_BOOL,
2398 .p_class = P_GLOBAL,
2399 .ptr = &Globals.paranoid_server_security,
2400 .special = NULL,
2401 .enum_list = NULL,
2402 .flags = FLAG_ADVANCED,
2405 .label = "max disk size",
2406 .type = P_INTEGER,
2407 .p_class = P_GLOBAL,
2408 .ptr = &Globals.maxdisksize,
2409 .special = NULL,
2410 .enum_list = NULL,
2411 .flags = FLAG_ADVANCED,
2414 .label = "max open files",
2415 .type = P_INTEGER,
2416 .p_class = P_GLOBAL,
2417 .ptr = &Globals.max_open_files,
2418 .special = NULL,
2419 .enum_list = NULL,
2420 .flags = FLAG_ADVANCED,
2423 .label = "min print space",
2424 .type = P_INTEGER,
2425 .p_class = P_LOCAL,
2426 .ptr = &sDefault.iMinPrintSpace,
2427 .special = NULL,
2428 .enum_list = NULL,
2429 .flags = FLAG_ADVANCED | FLAG_PRINT,
2432 .label = "socket options",
2433 .type = P_STRING,
2434 .p_class = P_GLOBAL,
2435 .ptr = &Globals.szSocketOptions,
2436 .special = NULL,
2437 .enum_list = NULL,
2438 .flags = FLAG_ADVANCED,
2441 .label = "strict allocate",
2442 .type = P_BOOL,
2443 .p_class = P_LOCAL,
2444 .ptr = &sDefault.bStrictAllocate,
2445 .special = NULL,
2446 .enum_list = NULL,
2447 .flags = FLAG_ADVANCED | FLAG_SHARE,
2450 .label = "strict sync",
2451 .type = P_BOOL,
2452 .p_class = P_LOCAL,
2453 .ptr = &sDefault.bStrictSync,
2454 .special = NULL,
2455 .enum_list = NULL,
2456 .flags = FLAG_ADVANCED | FLAG_SHARE,
2459 .label = "sync always",
2460 .type = P_BOOL,
2461 .p_class = P_LOCAL,
2462 .ptr = &sDefault.bSyncAlways,
2463 .special = NULL,
2464 .enum_list = NULL,
2465 .flags = FLAG_ADVANCED | FLAG_SHARE,
2468 .label = "use mmap",
2469 .type = P_BOOL,
2470 .p_class = P_GLOBAL,
2471 .ptr = &Globals.bUseMmap,
2472 .special = NULL,
2473 .enum_list = NULL,
2474 .flags = FLAG_ADVANCED,
2477 .label = "use sendfile",
2478 .type = P_BOOL,
2479 .p_class = P_LOCAL,
2480 .ptr = &sDefault.bUseSendfile,
2481 .special = NULL,
2482 .enum_list = NULL,
2483 .flags = FLAG_ADVANCED | FLAG_SHARE,
2486 .label = "hostname lookups",
2487 .type = P_BOOL,
2488 .p_class = P_GLOBAL,
2489 .ptr = &Globals.bHostnameLookups,
2490 .special = NULL,
2491 .enum_list = NULL,
2492 .flags = FLAG_ADVANCED,
2495 .label = "write cache size",
2496 .type = P_INTEGER,
2497 .p_class = P_LOCAL,
2498 .ptr = &sDefault.iWriteCacheSize,
2499 .special = NULL,
2500 .enum_list = NULL,
2501 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2504 .label = "name cache timeout",
2505 .type = P_INTEGER,
2506 .p_class = P_GLOBAL,
2507 .ptr = &Globals.name_cache_timeout,
2508 .special = NULL,
2509 .enum_list = NULL,
2510 .flags = FLAG_ADVANCED,
2513 .label = "ctdbd socket",
2514 .type = P_STRING,
2515 .p_class = P_GLOBAL,
2516 .ptr = &Globals.ctdbdSocket,
2517 .special = NULL,
2518 .enum_list = NULL,
2519 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2522 .label = "cluster addresses",
2523 .type = P_LIST,
2524 .p_class = P_GLOBAL,
2525 .ptr = &Globals.szClusterAddresses,
2526 .special = NULL,
2527 .enum_list = NULL,
2528 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2531 .label = "clustering",
2532 .type = P_BOOL,
2533 .p_class = P_GLOBAL,
2534 .ptr = &Globals.clustering,
2535 .special = NULL,
2536 .enum_list = NULL,
2537 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2540 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2543 .label = "max reported print jobs",
2544 .type = P_INTEGER,
2545 .p_class = P_LOCAL,
2546 .ptr = &sDefault.iMaxReportedPrintJobs,
2547 .special = NULL,
2548 .enum_list = NULL,
2549 .flags = FLAG_ADVANCED | FLAG_PRINT,
2552 .label = "max print jobs",
2553 .type = P_INTEGER,
2554 .p_class = P_LOCAL,
2555 .ptr = &sDefault.iMaxPrintJobs,
2556 .special = NULL,
2557 .enum_list = NULL,
2558 .flags = FLAG_ADVANCED | FLAG_PRINT,
2561 .label = "load printers",
2562 .type = P_BOOL,
2563 .p_class = P_GLOBAL,
2564 .ptr = &Globals.bLoadPrinters,
2565 .special = NULL,
2566 .enum_list = NULL,
2567 .flags = FLAG_ADVANCED | FLAG_PRINT,
2570 .label = "printcap cache time",
2571 .type = P_INTEGER,
2572 .p_class = P_GLOBAL,
2573 .ptr = &Globals.PrintcapCacheTime,
2574 .special = NULL,
2575 .enum_list = NULL,
2576 .flags = FLAG_ADVANCED | FLAG_PRINT,
2579 .label = "printcap name",
2580 .type = P_STRING,
2581 .p_class = P_GLOBAL,
2582 .ptr = &Globals.szPrintcapname,
2583 .special = NULL,
2584 .enum_list = NULL,
2585 .flags = FLAG_ADVANCED | FLAG_PRINT,
2588 .label = "printcap",
2589 .type = P_STRING,
2590 .p_class = P_GLOBAL,
2591 .ptr = &Globals.szPrintcapname,
2592 .special = NULL,
2593 .enum_list = NULL,
2594 .flags = FLAG_HIDE,
2597 .label = "printable",
2598 .type = P_BOOL,
2599 .p_class = P_LOCAL,
2600 .ptr = &sDefault.bPrint_ok,
2601 .special = NULL,
2602 .enum_list = NULL,
2603 .flags = FLAG_ADVANCED | FLAG_PRINT,
2606 .label = "print ok",
2607 .type = P_BOOL,
2608 .p_class = P_LOCAL,
2609 .ptr = &sDefault.bPrint_ok,
2610 .special = NULL,
2611 .enum_list = NULL,
2612 .flags = FLAG_HIDE,
2615 .label = "printing",
2616 .type = P_ENUM,
2617 .p_class = P_LOCAL,
2618 .ptr = &sDefault.iPrinting,
2619 .special = handle_printing,
2620 .enum_list = enum_printing,
2621 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2624 .label = "cups options",
2625 .type = P_STRING,
2626 .p_class = P_LOCAL,
2627 .ptr = &sDefault.szCupsOptions,
2628 .special = NULL,
2629 .enum_list = NULL,
2630 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2633 .label = "cups server",
2634 .type = P_STRING,
2635 .p_class = P_GLOBAL,
2636 .ptr = &Globals.szCupsServer,
2637 .special = NULL,
2638 .enum_list = NULL,
2639 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2642 .label = "cups encrypt",
2643 .type = P_ENUM,
2644 .p_class = P_GLOBAL,
2645 .ptr = &Globals.CupsEncrypt,
2646 .special = NULL,
2647 .enum_list = enum_bool_auto,
2648 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2652 .label = "cups connection timeout",
2653 .type = P_INTEGER,
2654 .p_class = P_GLOBAL,
2655 .ptr = &Globals.cups_connection_timeout,
2656 .special = NULL,
2657 .enum_list = NULL,
2658 .flags = FLAG_ADVANCED,
2661 .label = "iprint server",
2662 .type = P_STRING,
2663 .p_class = P_GLOBAL,
2664 .ptr = &Globals.szIPrintServer,
2665 .special = NULL,
2666 .enum_list = NULL,
2667 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2670 .label = "print command",
2671 .type = P_STRING,
2672 .p_class = P_LOCAL,
2673 .ptr = &sDefault.szPrintcommand,
2674 .special = NULL,
2675 .enum_list = NULL,
2676 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2679 .label = "disable spoolss",
2680 .type = P_BOOL,
2681 .p_class = P_GLOBAL,
2682 .ptr = &Globals.bDisableSpoolss,
2683 .special = NULL,
2684 .enum_list = NULL,
2685 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2688 .label = "enable spoolss",
2689 .type = P_BOOLREV,
2690 .p_class = P_GLOBAL,
2691 .ptr = &Globals.bDisableSpoolss,
2692 .special = NULL,
2693 .enum_list = NULL,
2694 .flags = FLAG_HIDE,
2697 .label = "lpq command",
2698 .type = P_STRING,
2699 .p_class = P_LOCAL,
2700 .ptr = &sDefault.szLpqcommand,
2701 .special = NULL,
2702 .enum_list = NULL,
2703 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2706 .label = "lprm command",
2707 .type = P_STRING,
2708 .p_class = P_LOCAL,
2709 .ptr = &sDefault.szLprmcommand,
2710 .special = NULL,
2711 .enum_list = NULL,
2712 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2715 .label = "lppause command",
2716 .type = P_STRING,
2717 .p_class = P_LOCAL,
2718 .ptr = &sDefault.szLppausecommand,
2719 .special = NULL,
2720 .enum_list = NULL,
2721 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2724 .label = "lpresume command",
2725 .type = P_STRING,
2726 .p_class = P_LOCAL,
2727 .ptr = &sDefault.szLpresumecommand,
2728 .special = NULL,
2729 .enum_list = NULL,
2730 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2733 .label = "queuepause command",
2734 .type = P_STRING,
2735 .p_class = P_LOCAL,
2736 .ptr = &sDefault.szQueuepausecommand,
2737 .special = NULL,
2738 .enum_list = NULL,
2739 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2742 .label = "queueresume command",
2743 .type = P_STRING,
2744 .p_class = P_LOCAL,
2745 .ptr = &sDefault.szQueueresumecommand,
2746 .special = NULL,
2747 .enum_list = NULL,
2748 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2751 .label = "addport command",
2752 .type = P_STRING,
2753 .p_class = P_GLOBAL,
2754 .ptr = &Globals.szAddPortCommand,
2755 .special = NULL,
2756 .enum_list = NULL,
2757 .flags = FLAG_ADVANCED,
2760 .label = "enumports command",
2761 .type = P_STRING,
2762 .p_class = P_GLOBAL,
2763 .ptr = &Globals.szEnumPortsCommand,
2764 .special = NULL,
2765 .enum_list = NULL,
2766 .flags = FLAG_ADVANCED,
2769 .label = "addprinter command",
2770 .type = P_STRING,
2771 .p_class = P_GLOBAL,
2772 .ptr = &Globals.szAddPrinterCommand,
2773 .special = NULL,
2774 .enum_list = NULL,
2775 .flags = FLAG_ADVANCED,
2778 .label = "deleteprinter command",
2779 .type = P_STRING,
2780 .p_class = P_GLOBAL,
2781 .ptr = &Globals.szDeletePrinterCommand,
2782 .special = NULL,
2783 .enum_list = NULL,
2784 .flags = FLAG_ADVANCED,
2787 .label = "show add printer wizard",
2788 .type = P_BOOL,
2789 .p_class = P_GLOBAL,
2790 .ptr = &Globals.bMsAddPrinterWizard,
2791 .special = NULL,
2792 .enum_list = NULL,
2793 .flags = FLAG_ADVANCED,
2796 .label = "os2 driver map",
2797 .type = P_STRING,
2798 .p_class = P_GLOBAL,
2799 .ptr = &Globals.szOs2DriverMap,
2800 .special = NULL,
2801 .enum_list = NULL,
2802 .flags = FLAG_ADVANCED,
2806 .label = "printer name",
2807 .type = P_STRING,
2808 .p_class = P_LOCAL,
2809 .ptr = &sDefault.szPrintername,
2810 .special = NULL,
2811 .enum_list = NULL,
2812 .flags = FLAG_ADVANCED | FLAG_PRINT,
2815 .label = "printer",
2816 .type = P_STRING,
2817 .p_class = P_LOCAL,
2818 .ptr = &sDefault.szPrintername,
2819 .special = NULL,
2820 .enum_list = NULL,
2821 .flags = FLAG_HIDE,
2824 .label = "use client driver",
2825 .type = P_BOOL,
2826 .p_class = P_LOCAL,
2827 .ptr = &sDefault.bUseClientDriver,
2828 .special = NULL,
2829 .enum_list = NULL,
2830 .flags = FLAG_ADVANCED | FLAG_PRINT,
2833 .label = "default devmode",
2834 .type = P_BOOL,
2835 .p_class = P_LOCAL,
2836 .ptr = &sDefault.bDefaultDevmode,
2837 .special = NULL,
2838 .enum_list = NULL,
2839 .flags = FLAG_ADVANCED | FLAG_PRINT,
2842 .label = "force printername",
2843 .type = P_BOOL,
2844 .p_class = P_LOCAL,
2845 .ptr = &sDefault.bForcePrintername,
2846 .special = NULL,
2847 .enum_list = NULL,
2848 .flags = FLAG_ADVANCED | FLAG_PRINT,
2851 .label = "printjob username",
2852 .type = P_STRING,
2853 .p_class = P_LOCAL,
2854 .ptr = &sDefault.szPrintjobUsername,
2855 .special = NULL,
2856 .enum_list = NULL,
2857 .flags = FLAG_ADVANCED | FLAG_PRINT,
2860 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2863 .label = "mangling method",
2864 .type = P_STRING,
2865 .p_class = P_GLOBAL,
2866 .ptr = &Globals.szManglingMethod,
2867 .special = NULL,
2868 .enum_list = NULL,
2869 .flags = FLAG_ADVANCED,
2872 .label = "mangle prefix",
2873 .type = P_INTEGER,
2874 .p_class = P_GLOBAL,
2875 .ptr = &Globals.mangle_prefix,
2876 .special = NULL,
2877 .enum_list = NULL,
2878 .flags = FLAG_ADVANCED,
2882 .label = "default case",
2883 .type = P_ENUM,
2884 .p_class = P_LOCAL,
2885 .ptr = &sDefault.iDefaultCase,
2886 .special = NULL,
2887 .enum_list = enum_case,
2888 .flags = FLAG_ADVANCED | FLAG_SHARE,
2891 .label = "case sensitive",
2892 .type = P_ENUM,
2893 .p_class = P_LOCAL,
2894 .ptr = &sDefault.iCaseSensitive,
2895 .special = NULL,
2896 .enum_list = enum_bool_auto,
2897 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2900 .label = "casesignames",
2901 .type = P_ENUM,
2902 .p_class = P_LOCAL,
2903 .ptr = &sDefault.iCaseSensitive,
2904 .special = NULL,
2905 .enum_list = enum_bool_auto,
2906 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2909 .label = "preserve case",
2910 .type = P_BOOL,
2911 .p_class = P_LOCAL,
2912 .ptr = &sDefault.bCasePreserve,
2913 .special = NULL,
2914 .enum_list = NULL,
2915 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2918 .label = "short preserve case",
2919 .type = P_BOOL,
2920 .p_class = P_LOCAL,
2921 .ptr = &sDefault.bShortCasePreserve,
2922 .special = NULL,
2923 .enum_list = NULL,
2924 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2927 .label = "mangling char",
2928 .type = P_CHAR,
2929 .p_class = P_LOCAL,
2930 .ptr = &sDefault.magic_char,
2931 .special = NULL,
2932 .enum_list = NULL,
2933 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2936 .label = "hide dot files",
2937 .type = P_BOOL,
2938 .p_class = P_LOCAL,
2939 .ptr = &sDefault.bHideDotFiles,
2940 .special = NULL,
2941 .enum_list = NULL,
2942 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2945 .label = "hide special files",
2946 .type = P_BOOL,
2947 .p_class = P_LOCAL,
2948 .ptr = &sDefault.bHideSpecialFiles,
2949 .special = NULL,
2950 .enum_list = NULL,
2951 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2954 .label = "hide unreadable",
2955 .type = P_BOOL,
2956 .p_class = P_LOCAL,
2957 .ptr = &sDefault.bHideUnReadable,
2958 .special = NULL,
2959 .enum_list = NULL,
2960 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2963 .label = "hide unwriteable files",
2964 .type = P_BOOL,
2965 .p_class = P_LOCAL,
2966 .ptr = &sDefault.bHideUnWriteableFiles,
2967 .special = NULL,
2968 .enum_list = NULL,
2969 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2972 .label = "delete veto files",
2973 .type = P_BOOL,
2974 .p_class = P_LOCAL,
2975 .ptr = &sDefault.bDeleteVetoFiles,
2976 .special = NULL,
2977 .enum_list = NULL,
2978 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2981 .label = "veto files",
2982 .type = P_STRING,
2983 .p_class = P_LOCAL,
2984 .ptr = &sDefault.szVetoFiles,
2985 .special = NULL,
2986 .enum_list = NULL,
2987 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2990 .label = "hide files",
2991 .type = P_STRING,
2992 .p_class = P_LOCAL,
2993 .ptr = &sDefault.szHideFiles,
2994 .special = NULL,
2995 .enum_list = NULL,
2996 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2999 .label = "veto oplock files",
3000 .type = P_STRING,
3001 .p_class = P_LOCAL,
3002 .ptr = &sDefault.szVetoOplockFiles,
3003 .special = NULL,
3004 .enum_list = NULL,
3005 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3008 .label = "map archive",
3009 .type = P_BOOL,
3010 .p_class = P_LOCAL,
3011 .ptr = &sDefault.bMap_archive,
3012 .special = NULL,
3013 .enum_list = NULL,
3014 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3017 .label = "map hidden",
3018 .type = P_BOOL,
3019 .p_class = P_LOCAL,
3020 .ptr = &sDefault.bMap_hidden,
3021 .special = NULL,
3022 .enum_list = NULL,
3023 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3026 .label = "map system",
3027 .type = P_BOOL,
3028 .p_class = P_LOCAL,
3029 .ptr = &sDefault.bMap_system,
3030 .special = NULL,
3031 .enum_list = NULL,
3032 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3035 .label = "map readonly",
3036 .type = P_ENUM,
3037 .p_class = P_LOCAL,
3038 .ptr = &sDefault.iMap_readonly,
3039 .special = NULL,
3040 .enum_list = enum_map_readonly,
3041 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3044 .label = "mangled names",
3045 .type = P_BOOL,
3046 .p_class = P_LOCAL,
3047 .ptr = &sDefault.bMangledNames,
3048 .special = NULL,
3049 .enum_list = NULL,
3050 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3053 .label = "max stat cache size",
3054 .type = P_INTEGER,
3055 .p_class = P_GLOBAL,
3056 .ptr = &Globals.iMaxStatCacheSize,
3057 .special = NULL,
3058 .enum_list = NULL,
3059 .flags = FLAG_ADVANCED,
3062 .label = "stat cache",
3063 .type = P_BOOL,
3064 .p_class = P_GLOBAL,
3065 .ptr = &Globals.bStatCache,
3066 .special = NULL,
3067 .enum_list = NULL,
3068 .flags = FLAG_ADVANCED,
3071 .label = "store create time",
3072 .type = P_BOOL,
3073 .p_class = P_LOCAL,
3074 .ptr = &sDefault.bStoreCreateTime,
3075 .special = NULL,
3076 .enum_list = NULL,
3077 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3080 .label = "store dos attributes",
3081 .type = P_BOOL,
3082 .p_class = P_LOCAL,
3083 .ptr = &sDefault.bStoreDosAttributes,
3084 .special = NULL,
3085 .enum_list = NULL,
3086 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3089 .label = "dmapi support",
3090 .type = P_BOOL,
3091 .p_class = P_LOCAL,
3092 .ptr = &sDefault.bDmapiSupport,
3093 .special = NULL,
3094 .enum_list = NULL,
3095 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3099 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3102 .label = "machine password timeout",
3103 .type = P_INTEGER,
3104 .p_class = P_GLOBAL,
3105 .ptr = &Globals.machine_password_timeout,
3106 .special = NULL,
3107 .enum_list = NULL,
3108 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3111 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3114 .label = "add user script",
3115 .type = P_STRING,
3116 .p_class = P_GLOBAL,
3117 .ptr = &Globals.szAddUserScript,
3118 .special = NULL,
3119 .enum_list = NULL,
3120 .flags = FLAG_ADVANCED,
3123 .label = "rename user script",
3124 .type = P_STRING,
3125 .p_class = P_GLOBAL,
3126 .ptr = &Globals.szRenameUserScript,
3127 .special = NULL,
3128 .enum_list = NULL,
3129 .flags = FLAG_ADVANCED,
3132 .label = "delete user script",
3133 .type = P_STRING,
3134 .p_class = P_GLOBAL,
3135 .ptr = &Globals.szDelUserScript,
3136 .special = NULL,
3137 .enum_list = NULL,
3138 .flags = FLAG_ADVANCED,
3141 .label = "add group script",
3142 .type = P_STRING,
3143 .p_class = P_GLOBAL,
3144 .ptr = &Globals.szAddGroupScript,
3145 .special = NULL,
3146 .enum_list = NULL,
3147 .flags = FLAG_ADVANCED,
3150 .label = "delete group script",
3151 .type = P_STRING,
3152 .p_class = P_GLOBAL,
3153 .ptr = &Globals.szDelGroupScript,
3154 .special = NULL,
3155 .enum_list = NULL,
3156 .flags = FLAG_ADVANCED,
3159 .label = "add user to group script",
3160 .type = P_STRING,
3161 .p_class = P_GLOBAL,
3162 .ptr = &Globals.szAddUserToGroupScript,
3163 .special = NULL,
3164 .enum_list = NULL,
3165 .flags = FLAG_ADVANCED,
3168 .label = "delete user from group script",
3169 .type = P_STRING,
3170 .p_class = P_GLOBAL,
3171 .ptr = &Globals.szDelUserFromGroupScript,
3172 .special = NULL,
3173 .enum_list = NULL,
3174 .flags = FLAG_ADVANCED,
3177 .label = "set primary group script",
3178 .type = P_STRING,
3179 .p_class = P_GLOBAL,
3180 .ptr = &Globals.szSetPrimaryGroupScript,
3181 .special = NULL,
3182 .enum_list = NULL,
3183 .flags = FLAG_ADVANCED,
3186 .label = "add machine script",
3187 .type = P_STRING,
3188 .p_class = P_GLOBAL,
3189 .ptr = &Globals.szAddMachineScript,
3190 .special = NULL,
3191 .enum_list = NULL,
3192 .flags = FLAG_ADVANCED,
3195 .label = "shutdown script",
3196 .type = P_STRING,
3197 .p_class = P_GLOBAL,
3198 .ptr = &Globals.szShutdownScript,
3199 .special = NULL,
3200 .enum_list = NULL,
3201 .flags = FLAG_ADVANCED,
3204 .label = "abort shutdown script",
3205 .type = P_STRING,
3206 .p_class = P_GLOBAL,
3207 .ptr = &Globals.szAbortShutdownScript,
3208 .special = NULL,
3209 .enum_list = NULL,
3210 .flags = FLAG_ADVANCED,
3213 .label = "username map script",
3214 .type = P_STRING,
3215 .p_class = P_GLOBAL,
3216 .ptr = &Globals.szUsernameMapScript,
3217 .special = NULL,
3218 .enum_list = NULL,
3219 .flags = FLAG_ADVANCED,
3222 .label = "logon script",
3223 .type = P_STRING,
3224 .p_class = P_GLOBAL,
3225 .ptr = &Globals.szLogonScript,
3226 .special = NULL,
3227 .enum_list = NULL,
3228 .flags = FLAG_ADVANCED,
3231 .label = "logon path",
3232 .type = P_STRING,
3233 .p_class = P_GLOBAL,
3234 .ptr = &Globals.szLogonPath,
3235 .special = NULL,
3236 .enum_list = NULL,
3237 .flags = FLAG_ADVANCED,
3240 .label = "logon drive",
3241 .type = P_STRING,
3242 .p_class = P_GLOBAL,
3243 .ptr = &Globals.szLogonDrive,
3244 .special = NULL,
3245 .enum_list = NULL,
3246 .flags = FLAG_ADVANCED,
3249 .label = "logon home",
3250 .type = P_STRING,
3251 .p_class = P_GLOBAL,
3252 .ptr = &Globals.szLogonHome,
3253 .special = NULL,
3254 .enum_list = NULL,
3255 .flags = FLAG_ADVANCED,
3258 .label = "domain logons",
3259 .type = P_BOOL,
3260 .p_class = P_GLOBAL,
3261 .ptr = &Globals.bDomainLogons,
3262 .special = NULL,
3263 .enum_list = NULL,
3264 .flags = FLAG_ADVANCED,
3268 .label = "init logon delayed hosts",
3269 .type = P_LIST,
3270 .p_class = P_GLOBAL,
3271 .ptr = &Globals.szInitLogonDelayedHosts,
3272 .flags = FLAG_ADVANCED,
3276 .label = "init logon delay",
3277 .type = P_INTEGER,
3278 .p_class = P_GLOBAL,
3279 .ptr = &Globals.InitLogonDelay,
3280 .flags = FLAG_ADVANCED,
3284 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3287 .label = "os level",
3288 .type = P_INTEGER,
3289 .p_class = P_GLOBAL,
3290 .ptr = &Globals.os_level,
3291 .special = NULL,
3292 .enum_list = NULL,
3293 .flags = FLAG_BASIC | FLAG_ADVANCED,
3296 .label = "lm announce",
3297 .type = P_ENUM,
3298 .p_class = P_GLOBAL,
3299 .ptr = &Globals.lm_announce,
3300 .special = NULL,
3301 .enum_list = enum_bool_auto,
3302 .flags = FLAG_ADVANCED,
3305 .label = "lm interval",
3306 .type = P_INTEGER,
3307 .p_class = P_GLOBAL,
3308 .ptr = &Globals.lm_interval,
3309 .special = NULL,
3310 .enum_list = NULL,
3311 .flags = FLAG_ADVANCED,
3314 .label = "preferred master",
3315 .type = P_ENUM,
3316 .p_class = P_GLOBAL,
3317 .ptr = &Globals.iPreferredMaster,
3318 .special = NULL,
3319 .enum_list = enum_bool_auto,
3320 .flags = FLAG_BASIC | FLAG_ADVANCED,
3323 .label = "prefered master",
3324 .type = P_ENUM,
3325 .p_class = P_GLOBAL,
3326 .ptr = &Globals.iPreferredMaster,
3327 .special = NULL,
3328 .enum_list = enum_bool_auto,
3329 .flags = FLAG_HIDE,
3332 .label = "local master",
3333 .type = P_BOOL,
3334 .p_class = P_GLOBAL,
3335 .ptr = &Globals.bLocalMaster,
3336 .special = NULL,
3337 .enum_list = NULL,
3338 .flags = FLAG_BASIC | FLAG_ADVANCED,
3341 .label = "domain master",
3342 .type = P_ENUM,
3343 .p_class = P_GLOBAL,
3344 .ptr = &Globals.iDomainMaster,
3345 .special = NULL,
3346 .enum_list = enum_bool_auto,
3347 .flags = FLAG_BASIC | FLAG_ADVANCED,
3350 .label = "browse list",
3351 .type = P_BOOL,
3352 .p_class = P_GLOBAL,
3353 .ptr = &Globals.bBrowseList,
3354 .special = NULL,
3355 .enum_list = NULL,
3356 .flags = FLAG_ADVANCED,
3359 .label = "browseable",
3360 .type = P_BOOL,
3361 .p_class = P_LOCAL,
3362 .ptr = &sDefault.bBrowseable,
3363 .special = NULL,
3364 .enum_list = NULL,
3365 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3368 .label = "browsable",
3369 .type = P_BOOL,
3370 .p_class = P_LOCAL,
3371 .ptr = &sDefault.bBrowseable,
3372 .special = NULL,
3373 .enum_list = NULL,
3374 .flags = FLAG_HIDE,
3377 .label = "access based share enum",
3378 .type = P_BOOL,
3379 .p_class = P_LOCAL,
3380 .ptr = &sDefault.bAccessBasedShareEnum,
3381 .special = NULL,
3382 .enum_list = NULL,
3383 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3386 .label = "enhanced browsing",
3387 .type = P_BOOL,
3388 .p_class = P_GLOBAL,
3389 .ptr = &Globals.enhanced_browsing,
3390 .special = NULL,
3391 .enum_list = NULL,
3392 .flags = FLAG_ADVANCED,
3395 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3398 .label = "dns proxy",
3399 .type = P_BOOL,
3400 .p_class = P_GLOBAL,
3401 .ptr = &Globals.bDNSproxy,
3402 .special = NULL,
3403 .enum_list = NULL,
3404 .flags = FLAG_ADVANCED,
3407 .label = "wins proxy",
3408 .type = P_BOOL,
3409 .p_class = P_GLOBAL,
3410 .ptr = &Globals.bWINSproxy,
3411 .special = NULL,
3412 .enum_list = NULL,
3413 .flags = FLAG_ADVANCED,
3416 .label = "wins server",
3417 .type = P_LIST,
3418 .p_class = P_GLOBAL,
3419 .ptr = &Globals.szWINSservers,
3420 .special = NULL,
3421 .enum_list = NULL,
3422 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3425 .label = "wins support",
3426 .type = P_BOOL,
3427 .p_class = P_GLOBAL,
3428 .ptr = &Globals.bWINSsupport,
3429 .special = NULL,
3430 .enum_list = NULL,
3431 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3434 .label = "wins hook",
3435 .type = P_STRING,
3436 .p_class = P_GLOBAL,
3437 .ptr = &Globals.szWINSHook,
3438 .special = NULL,
3439 .enum_list = NULL,
3440 .flags = FLAG_ADVANCED,
3443 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3446 .label = "blocking locks",
3447 .type = P_BOOL,
3448 .p_class = P_LOCAL,
3449 .ptr = &sDefault.bBlockingLocks,
3450 .special = NULL,
3451 .enum_list = NULL,
3452 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3455 .label = "csc policy",
3456 .type = P_ENUM,
3457 .p_class = P_LOCAL,
3458 .ptr = &sDefault.iCSCPolicy,
3459 .special = NULL,
3460 .enum_list = enum_csc_policy,
3461 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3464 .label = "fake oplocks",
3465 .type = P_BOOL,
3466 .p_class = P_LOCAL,
3467 .ptr = &sDefault.bFakeOplocks,
3468 .special = NULL,
3469 .enum_list = NULL,
3470 .flags = FLAG_ADVANCED | FLAG_SHARE,
3473 .label = "kernel oplocks",
3474 .type = P_BOOL,
3475 .p_class = P_GLOBAL,
3476 .ptr = &Globals.bKernelOplocks,
3477 .special = NULL,
3478 .enum_list = NULL,
3479 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3482 .label = "locking",
3483 .type = P_BOOL,
3484 .p_class = P_LOCAL,
3485 .ptr = &sDefault.bLocking,
3486 .special = NULL,
3487 .enum_list = NULL,
3488 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3491 .label = "lock spin time",
3492 .type = P_INTEGER,
3493 .p_class = P_GLOBAL,
3494 .ptr = &Globals.iLockSpinTime,
3495 .special = NULL,
3496 .enum_list = NULL,
3497 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3500 .label = "oplocks",
3501 .type = P_BOOL,
3502 .p_class = P_LOCAL,
3503 .ptr = &sDefault.bOpLocks,
3504 .special = NULL,
3505 .enum_list = NULL,
3506 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3509 .label = "level2 oplocks",
3510 .type = P_BOOL,
3511 .p_class = P_LOCAL,
3512 .ptr = &sDefault.bLevel2OpLocks,
3513 .special = NULL,
3514 .enum_list = NULL,
3515 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3518 .label = "oplock break wait time",
3519 .type = P_INTEGER,
3520 .p_class = P_GLOBAL,
3521 .ptr = &Globals.oplock_break_wait_time,
3522 .special = NULL,
3523 .enum_list = NULL,
3524 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3527 .label = "oplock contention limit",
3528 .type = P_INTEGER,
3529 .p_class = P_LOCAL,
3530 .ptr = &sDefault.iOplockContentionLimit,
3531 .special = NULL,
3532 .enum_list = NULL,
3533 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3536 .label = "posix locking",
3537 .type = P_BOOL,
3538 .p_class = P_LOCAL,
3539 .ptr = &sDefault.bPosixLocking,
3540 .special = NULL,
3541 .enum_list = NULL,
3542 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3545 .label = "strict locking",
3546 .type = P_ENUM,
3547 .p_class = P_LOCAL,
3548 .ptr = &sDefault.iStrictLocking,
3549 .special = NULL,
3550 .enum_list = enum_bool_auto,
3551 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3554 .label = "share modes",
3555 .type = P_BOOL,
3556 .p_class = P_LOCAL,
3557 .ptr = &sDefault.bShareModes,
3558 .special = NULL,
3559 .enum_list = NULL,
3560 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3563 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3566 .label = "ldap admin dn",
3567 .type = P_STRING,
3568 .p_class = P_GLOBAL,
3569 .ptr = &Globals.szLdapAdminDn,
3570 .special = NULL,
3571 .enum_list = NULL,
3572 .flags = FLAG_ADVANCED,
3575 .label = "ldap delete dn",
3576 .type = P_BOOL,
3577 .p_class = P_GLOBAL,
3578 .ptr = &Globals.ldap_delete_dn,
3579 .special = NULL,
3580 .enum_list = NULL,
3581 .flags = FLAG_ADVANCED,
3584 .label = "ldap group suffix",
3585 .type = P_STRING,
3586 .p_class = P_GLOBAL,
3587 .ptr = &Globals.szLdapGroupSuffix,
3588 .special = NULL,
3589 .enum_list = NULL,
3590 .flags = FLAG_ADVANCED,
3593 .label = "ldap idmap suffix",
3594 .type = P_STRING,
3595 .p_class = P_GLOBAL,
3596 .ptr = &Globals.szLdapIdmapSuffix,
3597 .special = NULL,
3598 .enum_list = NULL,
3599 .flags = FLAG_ADVANCED,
3602 .label = "ldap machine suffix",
3603 .type = P_STRING,
3604 .p_class = P_GLOBAL,
3605 .ptr = &Globals.szLdapMachineSuffix,
3606 .special = NULL,
3607 .enum_list = NULL,
3608 .flags = FLAG_ADVANCED,
3611 .label = "ldap passwd sync",
3612 .type = P_ENUM,
3613 .p_class = P_GLOBAL,
3614 .ptr = &Globals.ldap_passwd_sync,
3615 .special = NULL,
3616 .enum_list = enum_ldap_passwd_sync,
3617 .flags = FLAG_ADVANCED,
3620 .label = "ldap password sync",
3621 .type = P_ENUM,
3622 .p_class = P_GLOBAL,
3623 .ptr = &Globals.ldap_passwd_sync,
3624 .special = NULL,
3625 .enum_list = enum_ldap_passwd_sync,
3626 .flags = FLAG_HIDE,
3629 .label = "ldap replication sleep",
3630 .type = P_INTEGER,
3631 .p_class = P_GLOBAL,
3632 .ptr = &Globals.ldap_replication_sleep,
3633 .special = NULL,
3634 .enum_list = NULL,
3635 .flags = FLAG_ADVANCED,
3638 .label = "ldap suffix",
3639 .type = P_STRING,
3640 .p_class = P_GLOBAL,
3641 .ptr = &Globals.szLdapSuffix,
3642 .special = NULL,
3643 .enum_list = NULL,
3644 .flags = FLAG_ADVANCED,
3647 .label = "ldap ssl",
3648 .type = P_ENUM,
3649 .p_class = P_GLOBAL,
3650 .ptr = &Globals.ldap_ssl,
3651 .special = NULL,
3652 .enum_list = enum_ldap_ssl,
3653 .flags = FLAG_ADVANCED,
3656 .label = "ldap ssl ads",
3657 .type = P_BOOL,
3658 .p_class = P_GLOBAL,
3659 .ptr = &Globals.ldap_ssl_ads,
3660 .special = NULL,
3661 .enum_list = NULL,
3662 .flags = FLAG_ADVANCED,
3665 .label = "ldap timeout",
3666 .type = P_INTEGER,
3667 .p_class = P_GLOBAL,
3668 .ptr = &Globals.ldap_timeout,
3669 .special = NULL,
3670 .enum_list = NULL,
3671 .flags = FLAG_ADVANCED,
3674 .label = "ldap connection timeout",
3675 .type = P_INTEGER,
3676 .p_class = P_GLOBAL,
3677 .ptr = &Globals.ldap_connection_timeout,
3678 .special = NULL,
3679 .enum_list = NULL,
3680 .flags = FLAG_ADVANCED,
3683 .label = "ldap page size",
3684 .type = P_INTEGER,
3685 .p_class = P_GLOBAL,
3686 .ptr = &Globals.ldap_page_size,
3687 .special = NULL,
3688 .enum_list = NULL,
3689 .flags = FLAG_ADVANCED,
3692 .label = "ldap user suffix",
3693 .type = P_STRING,
3694 .p_class = P_GLOBAL,
3695 .ptr = &Globals.szLdapUserSuffix,
3696 .special = NULL,
3697 .enum_list = NULL,
3698 .flags = FLAG_ADVANCED,
3701 .label = "ldap debug level",
3702 .type = P_INTEGER,
3703 .p_class = P_GLOBAL,
3704 .ptr = &Globals.ldap_debug_level,
3705 .special = handle_ldap_debug_level,
3706 .enum_list = NULL,
3707 .flags = FLAG_ADVANCED,
3710 .label = "ldap debug threshold",
3711 .type = P_INTEGER,
3712 .p_class = P_GLOBAL,
3713 .ptr = &Globals.ldap_debug_threshold,
3714 .special = NULL,
3715 .enum_list = NULL,
3716 .flags = FLAG_ADVANCED,
3719 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3722 .label = "eventlog list",
3723 .type = P_LIST,
3724 .p_class = P_GLOBAL,
3725 .ptr = &Globals.szEventLogs,
3726 .special = NULL,
3727 .enum_list = NULL,
3728 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3731 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3734 .label = "add share command",
3735 .type = P_STRING,
3736 .p_class = P_GLOBAL,
3737 .ptr = &Globals.szAddShareCommand,
3738 .special = NULL,
3739 .enum_list = NULL,
3740 .flags = FLAG_ADVANCED,
3743 .label = "change share command",
3744 .type = P_STRING,
3745 .p_class = P_GLOBAL,
3746 .ptr = &Globals.szChangeShareCommand,
3747 .special = NULL,
3748 .enum_list = NULL,
3749 .flags = FLAG_ADVANCED,
3752 .label = "delete share command",
3753 .type = P_STRING,
3754 .p_class = P_GLOBAL,
3755 .ptr = &Globals.szDeleteShareCommand,
3756 .special = NULL,
3757 .enum_list = NULL,
3758 .flags = FLAG_ADVANCED,
3761 .label = "config file",
3762 .type = P_STRING,
3763 .p_class = P_GLOBAL,
3764 .ptr = &Globals.szConfigFile,
3765 .special = NULL,
3766 .enum_list = NULL,
3767 .flags = FLAG_HIDE|FLAG_META,
3770 .label = "preload",
3771 .type = P_STRING,
3772 .p_class = P_GLOBAL,
3773 .ptr = &Globals.szAutoServices,
3774 .special = NULL,
3775 .enum_list = NULL,
3776 .flags = FLAG_ADVANCED,
3779 .label = "auto services",
3780 .type = P_STRING,
3781 .p_class = P_GLOBAL,
3782 .ptr = &Globals.szAutoServices,
3783 .special = NULL,
3784 .enum_list = NULL,
3785 .flags = FLAG_ADVANCED,
3788 .label = "lock directory",
3789 .type = P_STRING,
3790 .p_class = P_GLOBAL,
3791 .ptr = &Globals.szLockDir,
3792 .special = NULL,
3793 .enum_list = NULL,
3794 .flags = FLAG_ADVANCED,
3797 .label = "lock dir",
3798 .type = P_STRING,
3799 .p_class = P_GLOBAL,
3800 .ptr = &Globals.szLockDir,
3801 .special = NULL,
3802 .enum_list = NULL,
3803 .flags = FLAG_HIDE,
3806 .label = "state directory",
3807 .type = P_STRING,
3808 .p_class = P_GLOBAL,
3809 .ptr = &Globals.szStateDir,
3810 .special = NULL,
3811 .enum_list = NULL,
3812 .flags = FLAG_ADVANCED,
3815 .label = "cache directory",
3816 .type = P_STRING,
3817 .p_class = P_GLOBAL,
3818 .ptr = &Globals.szCacheDir,
3819 .special = NULL,
3820 .enum_list = NULL,
3821 .flags = FLAG_ADVANCED,
3824 .label = "pid directory",
3825 .type = P_STRING,
3826 .p_class = P_GLOBAL,
3827 .ptr = &Globals.szPidDir,
3828 .special = NULL,
3829 .enum_list = NULL,
3830 .flags = FLAG_ADVANCED,
3832 #ifdef WITH_UTMP
3834 .label = "utmp directory",
3835 .type = P_STRING,
3836 .p_class = P_GLOBAL,
3837 .ptr = &Globals.szUtmpDir,
3838 .special = NULL,
3839 .enum_list = NULL,
3840 .flags = FLAG_ADVANCED,
3843 .label = "wtmp directory",
3844 .type = P_STRING,
3845 .p_class = P_GLOBAL,
3846 .ptr = &Globals.szWtmpDir,
3847 .special = NULL,
3848 .enum_list = NULL,
3849 .flags = FLAG_ADVANCED,
3852 .label = "utmp",
3853 .type = P_BOOL,
3854 .p_class = P_GLOBAL,
3855 .ptr = &Globals.bUtmp,
3856 .special = NULL,
3857 .enum_list = NULL,
3858 .flags = FLAG_ADVANCED,
3860 #endif
3862 .label = "default service",
3863 .type = P_STRING,
3864 .p_class = P_GLOBAL,
3865 .ptr = &Globals.szDefaultService,
3866 .special = NULL,
3867 .enum_list = NULL,
3868 .flags = FLAG_ADVANCED,
3871 .label = "default",
3872 .type = P_STRING,
3873 .p_class = P_GLOBAL,
3874 .ptr = &Globals.szDefaultService,
3875 .special = NULL,
3876 .enum_list = NULL,
3877 .flags = FLAG_ADVANCED,
3880 .label = "message command",
3881 .type = P_STRING,
3882 .p_class = P_GLOBAL,
3883 .ptr = &Globals.szMsgCommand,
3884 .special = NULL,
3885 .enum_list = NULL,
3886 .flags = FLAG_ADVANCED,
3889 .label = "dfree cache time",
3890 .type = P_INTEGER,
3891 .p_class = P_LOCAL,
3892 .ptr = &sDefault.iDfreeCacheTime,
3893 .special = NULL,
3894 .enum_list = NULL,
3895 .flags = FLAG_ADVANCED,
3898 .label = "dfree command",
3899 .type = P_STRING,
3900 .p_class = P_LOCAL,
3901 .ptr = &sDefault.szDfree,
3902 .special = NULL,
3903 .enum_list = NULL,
3904 .flags = FLAG_ADVANCED,
3907 .label = "get quota command",
3908 .type = P_STRING,
3909 .p_class = P_GLOBAL,
3910 .ptr = &Globals.szGetQuota,
3911 .special = NULL,
3912 .enum_list = NULL,
3913 .flags = FLAG_ADVANCED,
3916 .label = "set quota command",
3917 .type = P_STRING,
3918 .p_class = P_GLOBAL,
3919 .ptr = &Globals.szSetQuota,
3920 .special = NULL,
3921 .enum_list = NULL,
3922 .flags = FLAG_ADVANCED,
3925 .label = "remote announce",
3926 .type = P_STRING,
3927 .p_class = P_GLOBAL,
3928 .ptr = &Globals.szRemoteAnnounce,
3929 .special = NULL,
3930 .enum_list = NULL,
3931 .flags = FLAG_ADVANCED,
3934 .label = "remote browse sync",
3935 .type = P_STRING,
3936 .p_class = P_GLOBAL,
3937 .ptr = &Globals.szRemoteBrowseSync,
3938 .special = NULL,
3939 .enum_list = NULL,
3940 .flags = FLAG_ADVANCED,
3943 .label = "socket address",
3944 .type = P_STRING,
3945 .p_class = P_GLOBAL,
3946 .ptr = &Globals.szSocketAddress,
3947 .special = NULL,
3948 .enum_list = NULL,
3949 .flags = FLAG_ADVANCED,
3952 .label = "homedir map",
3953 .type = P_STRING,
3954 .p_class = P_GLOBAL,
3955 .ptr = &Globals.szNISHomeMapName,
3956 .special = NULL,
3957 .enum_list = NULL,
3958 .flags = FLAG_ADVANCED,
3961 .label = "afs username map",
3962 .type = P_STRING,
3963 .p_class = P_GLOBAL,
3964 .ptr = &Globals.szAfsUsernameMap,
3965 .special = NULL,
3966 .enum_list = NULL,
3967 .flags = FLAG_ADVANCED,
3970 .label = "afs token lifetime",
3971 .type = P_INTEGER,
3972 .p_class = P_GLOBAL,
3973 .ptr = &Globals.iAfsTokenLifetime,
3974 .special = NULL,
3975 .enum_list = NULL,
3976 .flags = FLAG_ADVANCED,
3979 .label = "log nt token command",
3980 .type = P_STRING,
3981 .p_class = P_GLOBAL,
3982 .ptr = &Globals.szLogNtTokenCommand,
3983 .special = NULL,
3984 .enum_list = NULL,
3985 .flags = FLAG_ADVANCED,
3988 .label = "time offset",
3989 .type = P_INTEGER,
3990 .p_class = P_GLOBAL,
3991 .ptr = &extra_time_offset,
3992 .special = NULL,
3993 .enum_list = NULL,
3994 .flags = FLAG_ADVANCED,
3997 .label = "NIS homedir",
3998 .type = P_BOOL,
3999 .p_class = P_GLOBAL,
4000 .ptr = &Globals.bNISHomeMap,
4001 .special = NULL,
4002 .enum_list = NULL,
4003 .flags = FLAG_ADVANCED,
4006 .label = "-valid",
4007 .type = P_BOOL,
4008 .p_class = P_LOCAL,
4009 .ptr = &sDefault.valid,
4010 .special = NULL,
4011 .enum_list = NULL,
4012 .flags = FLAG_HIDE,
4015 .label = "copy",
4016 .type = P_STRING,
4017 .p_class = P_LOCAL,
4018 .ptr = &sDefault.szCopy,
4019 .special = handle_copy,
4020 .enum_list = NULL,
4021 .flags = FLAG_HIDE,
4024 .label = "include",
4025 .type = P_STRING,
4026 .p_class = P_LOCAL,
4027 .ptr = &sDefault.szInclude,
4028 .special = handle_include,
4029 .enum_list = NULL,
4030 .flags = FLAG_HIDE|FLAG_META,
4033 .label = "preexec",
4034 .type = P_STRING,
4035 .p_class = P_LOCAL,
4036 .ptr = &sDefault.szPreExec,
4037 .special = NULL,
4038 .enum_list = NULL,
4039 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4042 .label = "exec",
4043 .type = P_STRING,
4044 .p_class = P_LOCAL,
4045 .ptr = &sDefault.szPreExec,
4046 .special = NULL,
4047 .enum_list = NULL,
4048 .flags = FLAG_ADVANCED,
4051 .label = "preexec close",
4052 .type = P_BOOL,
4053 .p_class = P_LOCAL,
4054 .ptr = &sDefault.bPreexecClose,
4055 .special = NULL,
4056 .enum_list = NULL,
4057 .flags = FLAG_ADVANCED | FLAG_SHARE,
4060 .label = "postexec",
4061 .type = P_STRING,
4062 .p_class = P_LOCAL,
4063 .ptr = &sDefault.szPostExec,
4064 .special = NULL,
4065 .enum_list = NULL,
4066 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4069 .label = "root preexec",
4070 .type = P_STRING,
4071 .p_class = P_LOCAL,
4072 .ptr = &sDefault.szRootPreExec,
4073 .special = NULL,
4074 .enum_list = NULL,
4075 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4078 .label = "root preexec close",
4079 .type = P_BOOL,
4080 .p_class = P_LOCAL,
4081 .ptr = &sDefault.bRootpreexecClose,
4082 .special = NULL,
4083 .enum_list = NULL,
4084 .flags = FLAG_ADVANCED | FLAG_SHARE,
4087 .label = "root postexec",
4088 .type = P_STRING,
4089 .p_class = P_LOCAL,
4090 .ptr = &sDefault.szRootPostExec,
4091 .special = NULL,
4092 .enum_list = NULL,
4093 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4096 .label = "available",
4097 .type = P_BOOL,
4098 .p_class = P_LOCAL,
4099 .ptr = &sDefault.bAvailable,
4100 .special = NULL,
4101 .enum_list = NULL,
4102 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4105 .label = "registry shares",
4106 .type = P_BOOL,
4107 .p_class = P_GLOBAL,
4108 .ptr = &Globals.bRegistryShares,
4109 .special = NULL,
4110 .enum_list = NULL,
4111 .flags = FLAG_ADVANCED,
4114 .label = "usershare allow guests",
4115 .type = P_BOOL,
4116 .p_class = P_GLOBAL,
4117 .ptr = &Globals.bUsershareAllowGuests,
4118 .special = NULL,
4119 .enum_list = NULL,
4120 .flags = FLAG_ADVANCED,
4123 .label = "usershare max shares",
4124 .type = P_INTEGER,
4125 .p_class = P_GLOBAL,
4126 .ptr = &Globals.iUsershareMaxShares,
4127 .special = NULL,
4128 .enum_list = NULL,
4129 .flags = FLAG_ADVANCED,
4132 .label = "usershare owner only",
4133 .type = P_BOOL,
4134 .p_class = P_GLOBAL,
4135 .ptr = &Globals.bUsershareOwnerOnly,
4136 .special = NULL,
4137 .enum_list = NULL,
4138 .flags = FLAG_ADVANCED,
4141 .label = "usershare path",
4142 .type = P_STRING,
4143 .p_class = P_GLOBAL,
4144 .ptr = &Globals.szUsersharePath,
4145 .special = NULL,
4146 .enum_list = NULL,
4147 .flags = FLAG_ADVANCED,
4150 .label = "usershare prefix allow list",
4151 .type = P_LIST,
4152 .p_class = P_GLOBAL,
4153 .ptr = &Globals.szUsersharePrefixAllowList,
4154 .special = NULL,
4155 .enum_list = NULL,
4156 .flags = FLAG_ADVANCED,
4159 .label = "usershare prefix deny list",
4160 .type = P_LIST,
4161 .p_class = P_GLOBAL,
4162 .ptr = &Globals.szUsersharePrefixDenyList,
4163 .special = NULL,
4164 .enum_list = NULL,
4165 .flags = FLAG_ADVANCED,
4168 .label = "usershare template share",
4169 .type = P_STRING,
4170 .p_class = P_GLOBAL,
4171 .ptr = &Globals.szUsershareTemplateShare,
4172 .special = NULL,
4173 .enum_list = NULL,
4174 .flags = FLAG_ADVANCED,
4177 .label = "volume",
4178 .type = P_STRING,
4179 .p_class = P_LOCAL,
4180 .ptr = &sDefault.volume,
4181 .special = NULL,
4182 .enum_list = NULL,
4183 .flags = FLAG_ADVANCED | FLAG_SHARE,
4186 .label = "fstype",
4187 .type = P_STRING,
4188 .p_class = P_LOCAL,
4189 .ptr = &sDefault.fstype,
4190 .special = NULL,
4191 .enum_list = NULL,
4192 .flags = FLAG_ADVANCED | FLAG_SHARE,
4195 .label = "set directory",
4196 .type = P_BOOLREV,
4197 .p_class = P_LOCAL,
4198 .ptr = &sDefault.bNo_set_dir,
4199 .special = NULL,
4200 .enum_list = NULL,
4201 .flags = FLAG_ADVANCED | FLAG_SHARE,
4204 .label = "wide links",
4205 .type = P_BOOL,
4206 .p_class = P_LOCAL,
4207 .ptr = &sDefault.bWidelinks,
4208 .special = NULL,
4209 .enum_list = NULL,
4210 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4213 .label = "follow symlinks",
4214 .type = P_BOOL,
4215 .p_class = P_LOCAL,
4216 .ptr = &sDefault.bSymlinks,
4217 .special = NULL,
4218 .enum_list = NULL,
4219 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4222 .label = "dont descend",
4223 .type = P_STRING,
4224 .p_class = P_LOCAL,
4225 .ptr = &sDefault.szDontdescend,
4226 .special = NULL,
4227 .enum_list = NULL,
4228 .flags = FLAG_ADVANCED | FLAG_SHARE,
4231 .label = "magic script",
4232 .type = P_STRING,
4233 .p_class = P_LOCAL,
4234 .ptr = &sDefault.szMagicScript,
4235 .special = NULL,
4236 .enum_list = NULL,
4237 .flags = FLAG_ADVANCED | FLAG_SHARE,
4240 .label = "magic output",
4241 .type = P_STRING,
4242 .p_class = P_LOCAL,
4243 .ptr = &sDefault.szMagicOutput,
4244 .special = NULL,
4245 .enum_list = NULL,
4246 .flags = FLAG_ADVANCED | FLAG_SHARE,
4249 .label = "delete readonly",
4250 .type = P_BOOL,
4251 .p_class = P_LOCAL,
4252 .ptr = &sDefault.bDeleteReadonly,
4253 .special = NULL,
4254 .enum_list = NULL,
4255 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4258 .label = "dos filemode",
4259 .type = P_BOOL,
4260 .p_class = P_LOCAL,
4261 .ptr = &sDefault.bDosFilemode,
4262 .special = NULL,
4263 .enum_list = NULL,
4264 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4267 .label = "dos filetimes",
4268 .type = P_BOOL,
4269 .p_class = P_LOCAL,
4270 .ptr = &sDefault.bDosFiletimes,
4271 .special = NULL,
4272 .enum_list = NULL,
4273 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4276 .label = "dos filetime resolution",
4277 .type = P_BOOL,
4278 .p_class = P_LOCAL,
4279 .ptr = &sDefault.bDosFiletimeResolution,
4280 .special = NULL,
4281 .enum_list = NULL,
4282 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4285 .label = "fake directory create times",
4286 .type = P_BOOL,
4287 .p_class = P_GLOBAL,
4288 .ptr = &Globals.bFakeDirCreateTimes,
4289 .special = NULL,
4290 .enum_list = NULL,
4291 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
4294 .label = "panic action",
4295 .type = P_STRING,
4296 .p_class = P_GLOBAL,
4297 .ptr = &Globals.szPanicAction,
4298 .special = NULL,
4299 .enum_list = NULL,
4300 .flags = FLAG_ADVANCED,
4303 .label = "perfcount module",
4304 .type = P_STRING,
4305 .p_class = P_GLOBAL,
4306 .ptr = &Globals.szSMBPerfcountModule,
4307 .special = NULL,
4308 .enum_list = NULL,
4309 .flags = FLAG_ADVANCED,
4312 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4315 .label = "vfs objects",
4316 .type = P_LIST,
4317 .p_class = P_LOCAL,
4318 .ptr = &sDefault.szVfsObjects,
4319 .special = NULL,
4320 .enum_list = NULL,
4321 .flags = FLAG_ADVANCED | FLAG_SHARE,
4324 .label = "vfs object",
4325 .type = P_LIST,
4326 .p_class = P_LOCAL,
4327 .ptr = &sDefault.szVfsObjects,
4328 .special = NULL,
4329 .enum_list = NULL,
4330 .flags = FLAG_HIDE,
4334 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4337 .label = "msdfs root",
4338 .type = P_BOOL,
4339 .p_class = P_LOCAL,
4340 .ptr = &sDefault.bMSDfsRoot,
4341 .special = NULL,
4342 .enum_list = NULL,
4343 .flags = FLAG_ADVANCED | FLAG_SHARE,
4346 .label = "msdfs proxy",
4347 .type = P_STRING,
4348 .p_class = P_LOCAL,
4349 .ptr = &sDefault.szMSDfsProxy,
4350 .special = NULL,
4351 .enum_list = NULL,
4352 .flags = FLAG_ADVANCED | FLAG_SHARE,
4355 .label = "host msdfs",
4356 .type = P_BOOL,
4357 .p_class = P_GLOBAL,
4358 .ptr = &Globals.bHostMSDfs,
4359 .special = NULL,
4360 .enum_list = NULL,
4361 .flags = FLAG_ADVANCED,
4364 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4367 .label = "passdb expand explicit",
4368 .type = P_BOOL,
4369 .p_class = P_GLOBAL,
4370 .ptr = &Globals.bPassdbExpandExplicit,
4371 .special = NULL,
4372 .enum_list = NULL,
4373 .flags = FLAG_ADVANCED,
4376 .label = "idmap backend",
4377 .type = P_STRING,
4378 .p_class = P_GLOBAL,
4379 .ptr = &Globals.szIdmapBackend,
4380 .special = NULL,
4381 .enum_list = NULL,
4382 .flags = FLAG_ADVANCED,
4385 .label = "idmap alloc backend",
4386 .type = P_STRING,
4387 .p_class = P_GLOBAL,
4388 .ptr = &Globals.szIdmapAllocBackend,
4389 .special = NULL,
4390 .enum_list = NULL,
4391 .flags = FLAG_ADVANCED,
4394 .label = "idmap cache time",
4395 .type = P_INTEGER,
4396 .p_class = P_GLOBAL,
4397 .ptr = &Globals.iIdmapCacheTime,
4398 .special = NULL,
4399 .enum_list = NULL,
4400 .flags = FLAG_ADVANCED,
4403 .label = "idmap negative cache time",
4404 .type = P_INTEGER,
4405 .p_class = P_GLOBAL,
4406 .ptr = &Globals.iIdmapNegativeCacheTime,
4407 .special = NULL,
4408 .enum_list = NULL,
4409 .flags = FLAG_ADVANCED,
4412 .label = "idmap uid",
4413 .type = P_STRING,
4414 .p_class = P_GLOBAL,
4415 .ptr = &Globals.szIdmapUID,
4416 .special = handle_idmap_uid,
4417 .enum_list = NULL,
4418 .flags = FLAG_ADVANCED,
4421 .label = "winbind uid",
4422 .type = P_STRING,
4423 .p_class = P_GLOBAL,
4424 .ptr = &Globals.szIdmapUID,
4425 .special = handle_idmap_uid,
4426 .enum_list = NULL,
4427 .flags = FLAG_HIDE,
4430 .label = "idmap gid",
4431 .type = P_STRING,
4432 .p_class = P_GLOBAL,
4433 .ptr = &Globals.szIdmapGID,
4434 .special = handle_idmap_gid,
4435 .enum_list = NULL,
4436 .flags = FLAG_ADVANCED,
4439 .label = "winbind gid",
4440 .type = P_STRING,
4441 .p_class = P_GLOBAL,
4442 .ptr = &Globals.szIdmapGID,
4443 .special = handle_idmap_gid,
4444 .enum_list = NULL,
4445 .flags = FLAG_HIDE,
4448 .label = "template homedir",
4449 .type = P_STRING,
4450 .p_class = P_GLOBAL,
4451 .ptr = &Globals.szTemplateHomedir,
4452 .special = NULL,
4453 .enum_list = NULL,
4454 .flags = FLAG_ADVANCED,
4457 .label = "template shell",
4458 .type = P_STRING,
4459 .p_class = P_GLOBAL,
4460 .ptr = &Globals.szTemplateShell,
4461 .special = NULL,
4462 .enum_list = NULL,
4463 .flags = FLAG_ADVANCED,
4466 .label = "winbind separator",
4467 .type = P_STRING,
4468 .p_class = P_GLOBAL,
4469 .ptr = &Globals.szWinbindSeparator,
4470 .special = NULL,
4471 .enum_list = NULL,
4472 .flags = FLAG_ADVANCED,
4475 .label = "winbind cache time",
4476 .type = P_INTEGER,
4477 .p_class = P_GLOBAL,
4478 .ptr = &Globals.winbind_cache_time,
4479 .special = NULL,
4480 .enum_list = NULL,
4481 .flags = FLAG_ADVANCED,
4484 .label = "winbind reconnect delay",
4485 .type = P_INTEGER,
4486 .p_class = P_GLOBAL,
4487 .ptr = &Globals.winbind_reconnect_delay,
4488 .special = NULL,
4489 .enum_list = NULL,
4490 .flags = FLAG_ADVANCED,
4493 .label = "winbind enum users",
4494 .type = P_BOOL,
4495 .p_class = P_GLOBAL,
4496 .ptr = &Globals.bWinbindEnumUsers,
4497 .special = NULL,
4498 .enum_list = NULL,
4499 .flags = FLAG_ADVANCED,
4502 .label = "winbind enum groups",
4503 .type = P_BOOL,
4504 .p_class = P_GLOBAL,
4505 .ptr = &Globals.bWinbindEnumGroups,
4506 .special = NULL,
4507 .enum_list = NULL,
4508 .flags = FLAG_ADVANCED,
4511 .label = "winbind use default domain",
4512 .type = P_BOOL,
4513 .p_class = P_GLOBAL,
4514 .ptr = &Globals.bWinbindUseDefaultDomain,
4515 .special = NULL,
4516 .enum_list = NULL,
4517 .flags = FLAG_ADVANCED,
4520 .label = "winbind trusted domains only",
4521 .type = P_BOOL,
4522 .p_class = P_GLOBAL,
4523 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4524 .special = NULL,
4525 .enum_list = NULL,
4526 .flags = FLAG_ADVANCED,
4529 .label = "winbind nested groups",
4530 .type = P_BOOL,
4531 .p_class = P_GLOBAL,
4532 .ptr = &Globals.bWinbindNestedGroups,
4533 .special = NULL,
4534 .enum_list = NULL,
4535 .flags = FLAG_ADVANCED,
4538 .label = "winbind expand groups",
4539 .type = P_INTEGER,
4540 .p_class = P_GLOBAL,
4541 .ptr = &Globals.winbind_expand_groups,
4542 .special = NULL,
4543 .enum_list = NULL,
4544 .flags = FLAG_ADVANCED,
4547 .label = "winbind nss info",
4548 .type = P_LIST,
4549 .p_class = P_GLOBAL,
4550 .ptr = &Globals.szWinbindNssInfo,
4551 .special = NULL,
4552 .enum_list = NULL,
4553 .flags = FLAG_ADVANCED,
4556 .label = "winbind refresh tickets",
4557 .type = P_BOOL,
4558 .p_class = P_GLOBAL,
4559 .ptr = &Globals.bWinbindRefreshTickets,
4560 .special = NULL,
4561 .enum_list = NULL,
4562 .flags = FLAG_ADVANCED,
4565 .label = "winbind offline logon",
4566 .type = P_BOOL,
4567 .p_class = P_GLOBAL,
4568 .ptr = &Globals.bWinbindOfflineLogon,
4569 .special = NULL,
4570 .enum_list = NULL,
4571 .flags = FLAG_ADVANCED,
4574 .label = "winbind normalize names",
4575 .type = P_BOOL,
4576 .p_class = P_GLOBAL,
4577 .ptr = &Globals.bWinbindNormalizeNames,
4578 .special = NULL,
4579 .enum_list = NULL,
4580 .flags = FLAG_ADVANCED,
4583 .label = "winbind rpc only",
4584 .type = P_BOOL,
4585 .p_class = P_GLOBAL,
4586 .ptr = &Globals.bWinbindRpcOnly,
4587 .special = NULL,
4588 .enum_list = NULL,
4589 .flags = FLAG_ADVANCED,
4592 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4595 /***************************************************************************
4596 Initialise the sDefault parameter structure for the printer values.
4597 ***************************************************************************/
4599 static void init_printer_values(struct service *pService)
4601 /* choose defaults depending on the type of printing */
4602 switch (pService->iPrinting) {
4603 case PRINT_BSD:
4604 case PRINT_AIX:
4605 case PRINT_LPRNT:
4606 case PRINT_LPROS2:
4607 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4608 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4609 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4610 break;
4612 case PRINT_LPRNG:
4613 case PRINT_PLP:
4614 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4615 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4616 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4617 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4618 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4619 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4620 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4621 break;
4623 case PRINT_CUPS:
4624 case PRINT_IPRINT:
4625 #ifdef HAVE_CUPS
4626 /* set the lpq command to contain the destination printer
4627 name only. This is used by cups_queue_get() */
4628 string_set(&pService->szLpqcommand, "%p");
4629 string_set(&pService->szLprmcommand, "");
4630 string_set(&pService->szPrintcommand, "");
4631 string_set(&pService->szLppausecommand, "");
4632 string_set(&pService->szLpresumecommand, "");
4633 string_set(&pService->szQueuepausecommand, "");
4634 string_set(&pService->szQueueresumecommand, "");
4635 #else
4636 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4637 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4638 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4639 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4640 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4641 string_set(&pService->szQueuepausecommand, "disable '%p'");
4642 string_set(&pService->szQueueresumecommand, "enable '%p'");
4643 #endif /* HAVE_CUPS */
4644 break;
4646 case PRINT_SYSV:
4647 case PRINT_HPUX:
4648 string_set(&pService->szLpqcommand, "lpstat -o%p");
4649 string_set(&pService->szLprmcommand, "cancel %p-%j");
4650 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4651 string_set(&pService->szQueuepausecommand, "disable %p");
4652 string_set(&pService->szQueueresumecommand, "enable %p");
4653 #ifndef HPUX
4654 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4655 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4656 #endif /* HPUX */
4657 break;
4659 case PRINT_QNX:
4660 string_set(&pService->szLpqcommand, "lpq -P%p");
4661 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4662 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4663 break;
4665 #ifdef DEVELOPER
4666 case PRINT_TEST:
4667 case PRINT_VLP:
4668 string_set(&pService->szPrintcommand, "vlp print %p %s");
4669 string_set(&pService->szLpqcommand, "vlp lpq %p");
4670 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4671 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4672 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4673 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4674 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4675 break;
4676 #endif /* DEVELOPER */
4681 * Function to return the default value for the maximum number of open
4682 * file descriptors permitted. This function tries to consult the
4683 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4684 * the smaller of those.
4686 static int max_open_files(void)
4688 int sysctl_max = MAX_OPEN_FILES;
4689 int rlimit_max = MAX_OPEN_FILES;
4691 #ifdef HAVE_SYSCTLBYNAME
4693 size_t size = sizeof(sysctl_max);
4694 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4697 #endif
4699 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4701 struct rlimit rl;
4703 ZERO_STRUCT(rl);
4705 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4706 rlimit_max = rl.rlim_cur;
4708 #if defined(RLIM_INFINITY)
4709 if(rl.rlim_cur == RLIM_INFINITY)
4710 rlimit_max = MAX_OPEN_FILES;
4712 #endif
4713 #endif
4715 return MIN(sysctl_max, rlimit_max);
4719 * Common part of freeing allocated data for one parameter.
4721 static void free_one_parameter_common(void *parm_ptr,
4722 struct parm_struct parm)
4724 if ((parm.type == P_STRING) ||
4725 (parm.type == P_USTRING))
4727 string_free((char**)parm_ptr);
4728 } else if (parm.type == P_LIST) {
4729 TALLOC_FREE(*((char***)parm_ptr));
4734 * Free the allocated data for one parameter for a share
4735 * given as a service struct.
4737 static void free_one_parameter(struct service *service,
4738 struct parm_struct parm)
4740 void *parm_ptr;
4742 if (parm.p_class != P_LOCAL) {
4743 return;
4746 parm_ptr = lp_local_ptr(service, parm.ptr);
4748 free_one_parameter_common(parm_ptr, parm);
4752 * Free the allocated parameter data of a share given
4753 * as a service struct.
4755 static void free_parameters(struct service *service)
4757 uint32_t i;
4759 for (i=0; parm_table[i].label; i++) {
4760 free_one_parameter(service, parm_table[i]);
4765 * Free the allocated data for one parameter for a given share
4766 * specified by an snum.
4768 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4770 void *parm_ptr;
4772 if (parm.ptr == NULL) {
4773 return;
4776 if (snum < 0) {
4777 parm_ptr = parm.ptr;
4778 } else if (parm.p_class != P_LOCAL) {
4779 return;
4780 } else {
4781 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4784 free_one_parameter_common(parm_ptr, parm);
4788 * Free the allocated parameter data for a share specified
4789 * by an snum.
4791 static void free_parameters_by_snum(int snum)
4793 uint32_t i;
4795 for (i=0; parm_table[i].label; i++) {
4796 free_one_parameter_by_snum(snum, parm_table[i]);
4801 * Free the allocated global parameters.
4803 static void free_global_parameters(void)
4805 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4808 /***************************************************************************
4809 Initialise the global parameter structure.
4810 ***************************************************************************/
4812 static void init_globals(bool first_time_only)
4814 static bool done_init = False;
4815 char *s = NULL;
4816 int i;
4818 /* If requested to initialize only once and we've already done it... */
4819 if (first_time_only && done_init) {
4820 /* ... then we have nothing more to do */
4821 return;
4824 if (!done_init) {
4825 /* The logfile can be set before this is invoked. Free it if so. */
4826 if (Globals.szLogFile != NULL) {
4827 string_free(&Globals.szLogFile);
4828 Globals.szLogFile = NULL;
4830 done_init = True;
4831 } else {
4832 free_global_parameters();
4835 memset((void *)&Globals, '\0', sizeof(Globals));
4837 for (i = 0; parm_table[i].label; i++) {
4838 if ((parm_table[i].type == P_STRING ||
4839 parm_table[i].type == P_USTRING) &&
4840 parm_table[i].ptr)
4842 string_set((char **)parm_table[i].ptr, "");
4846 string_set(&sDefault.fstype, FSTYPE_STRING);
4847 string_set(&sDefault.szPrintjobUsername, "%U");
4849 init_printer_values(&sDefault);
4852 DEBUG(3, ("Initialising global parameters\n"));
4854 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4855 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4857 /* use the new 'hash2' method by default, with a prefix of 1 */
4858 string_set(&Globals.szManglingMethod, "hash2");
4859 Globals.mangle_prefix = 1;
4861 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4863 /* using UTF8 by default allows us to support all chars */
4864 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4866 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4867 /* If the system supports nl_langinfo(), try to grab the value
4868 from the user's locale */
4869 string_set(&Globals.display_charset, "LOCALE");
4870 #else
4871 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4872 #endif
4874 /* Use codepage 850 as a default for the dos character set */
4875 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4878 * Allow the default PASSWD_CHAT to be overridden in local.h.
4880 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4882 set_global_myname(myhostname());
4883 string_set(&Globals.szNetbiosName,global_myname());
4885 set_global_myworkgroup(WORKGROUP);
4886 string_set(&Globals.szWorkgroup, lp_workgroup());
4888 string_set(&Globals.szPasswdProgram, "");
4889 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4890 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4891 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4892 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4893 string_set(&Globals.szSocketAddress, "0.0.0.0");
4895 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4896 smb_panic("init_globals: ENOMEM");
4898 string_set(&Globals.szServerString, s);
4899 SAFE_FREE(s);
4900 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4901 DEFAULT_MINOR_VERSION) < 0) {
4902 smb_panic("init_globals: ENOMEM");
4904 string_set(&Globals.szAnnounceVersion, s);
4905 SAFE_FREE(s);
4906 #ifdef DEVELOPER
4907 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4908 #endif
4910 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4912 string_set(&Globals.szLogonDrive, "");
4913 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4914 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4915 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4917 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4918 string_set(&Globals.szPasswordServer, "*");
4920 Globals.AlgorithmicRidBase = BASE_RID;
4922 Globals.bLoadPrinters = True;
4923 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4925 Globals.ConfigBackend = config_backend;
4927 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4928 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4929 Globals.max_xmit = 0x4104;
4930 Globals.max_mux = 50; /* This is *needed* for profile support. */
4931 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4932 Globals.bDisableSpoolss = False;
4933 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4934 Globals.pwordlevel = 0;
4935 Globals.unamelevel = 0;
4936 Globals.deadtime = 0;
4937 Globals.getwd_cache = true;
4938 Globals.bLargeReadwrite = True;
4939 Globals.max_log_size = 5000;
4940 Globals.max_open_files = max_open_files();
4941 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4942 Globals.maxprotocol = PROTOCOL_NT1;
4943 Globals.minprotocol = PROTOCOL_CORE;
4944 Globals.security = SEC_USER;
4945 Globals.paranoid_server_security = True;
4946 Globals.bEncryptPasswords = True;
4947 Globals.bUpdateEncrypt = False;
4948 Globals.clientSchannel = Auto;
4949 Globals.serverSchannel = Auto;
4950 Globals.bReadRaw = True;
4951 Globals.bWriteRaw = True;
4952 Globals.bNullPasswords = False;
4953 Globals.bObeyPamRestrictions = False;
4954 Globals.syslog = 1;
4955 Globals.bSyslogOnly = False;
4956 Globals.bTimestampLogs = True;
4957 string_set(&Globals.szLogLevel, "0");
4958 Globals.bDebugPrefixTimestamp = False;
4959 Globals.bDebugHiresTimestamp = False;
4960 Globals.bDebugPid = False;
4961 Globals.bDebugUid = False;
4962 Globals.bDebugClass = False;
4963 Globals.bEnableCoreFiles = True;
4964 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4965 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4966 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4967 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4968 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4969 Globals.lm_interval = 60;
4970 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4971 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4972 Globals.bNISHomeMap = False;
4973 #ifdef WITH_NISPLUS_HOME
4974 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4975 #else
4976 string_set(&Globals.szNISHomeMapName, "auto.home");
4977 #endif
4978 #endif
4979 Globals.bTimeServer = False;
4980 Globals.bBindInterfacesOnly = False;
4981 Globals.bUnixPasswdSync = False;
4982 Globals.bPamPasswordChange = False;
4983 Globals.bPasswdChatDebug = False;
4984 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4985 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
4986 Globals.bNTStatusSupport = True; /* Use NT status by default. */
4987 Globals.bStatCache = True; /* use stat cache by default */
4988 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4989 Globals.restrict_anonymous = 0;
4990 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
4991 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
4992 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
4993 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4994 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
4995 /* Note, that we will use NTLM2 session security (which is different), if it is available */
4997 Globals.map_to_guest = 0; /* By Default, "Never" */
4998 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4999 Globals.enhanced_browsing = true;
5000 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
5001 #ifdef MMAP_BLACKLIST
5002 Globals.bUseMmap = False;
5003 #else
5004 Globals.bUseMmap = True;
5005 #endif
5006 Globals.bUnixExtensions = True;
5007 Globals.bResetOnZeroVC = False;
5009 /* hostname lookups can be very expensive and are broken on
5010 a large number of sites (tridge) */
5011 Globals.bHostnameLookups = False;
5013 string_set(&Globals.szPassdbBackend, "tdbsam");
5014 string_set(&Globals.szLdapSuffix, "");
5015 string_set(&Globals.szLdapMachineSuffix, "");
5016 string_set(&Globals.szLdapUserSuffix, "");
5017 string_set(&Globals.szLdapGroupSuffix, "");
5018 string_set(&Globals.szLdapIdmapSuffix, "");
5020 string_set(&Globals.szLdapAdminDn, "");
5021 Globals.ldap_ssl = LDAP_SSL_START_TLS;
5022 Globals.ldap_ssl_ads = False;
5023 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
5024 Globals.ldap_delete_dn = False;
5025 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
5026 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
5027 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5028 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5030 Globals.ldap_debug_level = 0;
5031 Globals.ldap_debug_threshold = 10;
5033 /* This is what we tell the afs client. in reality we set the token
5034 * to never expire, though, when this runs out the afs client will
5035 * forget the token. Set to 0 to get NEVERDATE.*/
5036 Globals.iAfsTokenLifetime = 604800;
5037 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5039 /* these parameters are set to defaults that are more appropriate
5040 for the increasing samba install base:
5042 as a member of the workgroup, that will possibly become a
5043 _local_ master browser (lm = True). this is opposed to a forced
5044 local master browser startup (pm = True).
5046 doesn't provide WINS server service by default (wsupp = False),
5047 and doesn't provide domain master browser services by default, either.
5051 Globals.bMsAddPrinterWizard = True;
5052 Globals.os_level = 20;
5053 Globals.bLocalMaster = True;
5054 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5055 Globals.bDomainLogons = False;
5056 Globals.bBrowseList = True;
5057 Globals.bWINSsupport = False;
5058 Globals.bWINSproxy = False;
5060 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5061 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5063 Globals.bDNSproxy = True;
5065 /* this just means to use them if they exist */
5066 Globals.bKernelOplocks = True;
5068 Globals.bAllowTrustedDomains = True;
5069 string_set(&Globals.szIdmapBackend, "tdb");
5071 string_set(&Globals.szTemplateShell, "/bin/false");
5072 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5073 string_set(&Globals.szWinbindSeparator, "\\");
5075 string_set(&Globals.szCupsServer, "");
5076 string_set(&Globals.szIPrintServer, "");
5078 string_set(&Globals.ctdbdSocket, "");
5079 Globals.szClusterAddresses = NULL;
5080 Globals.clustering = False;
5082 Globals.winbind_cache_time = 300; /* 5 minutes */
5083 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5084 Globals.bWinbindEnumUsers = False;
5085 Globals.bWinbindEnumGroups = False;
5086 Globals.bWinbindUseDefaultDomain = False;
5087 Globals.bWinbindTrustedDomainsOnly = False;
5088 Globals.bWinbindNestedGroups = True;
5089 Globals.winbind_expand_groups = 1;
5090 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5091 Globals.bWinbindRefreshTickets = False;
5092 Globals.bWinbindOfflineLogon = False;
5094 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5095 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5097 Globals.bPassdbExpandExplicit = False;
5099 Globals.name_cache_timeout = 660; /* In seconds */
5101 Globals.bUseSpnego = True;
5102 Globals.bClientUseSpnego = True;
5104 Globals.client_signing = Auto;
5105 Globals.server_signing = False;
5107 Globals.bDeferSharingViolations = True;
5108 string_set(&Globals.smb_ports, SMB_PORTS);
5110 Globals.bEnablePrivileges = True;
5111 Globals.bHostMSDfs = True;
5112 Globals.bASUSupport = False;
5114 /* User defined shares. */
5115 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5116 smb_panic("init_globals: ENOMEM");
5118 string_set(&Globals.szUsersharePath, s);
5119 SAFE_FREE(s);
5120 string_set(&Globals.szUsershareTemplateShare, "");
5121 Globals.iUsershareMaxShares = 0;
5122 /* By default disallow sharing of directories not owned by the sharer. */
5123 Globals.bUsershareOwnerOnly = True;
5124 /* By default disallow guest access to usershares. */
5125 Globals.bUsershareAllowGuests = False;
5127 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5129 /* By default no shares out of the registry */
5130 Globals.bRegistryShares = False;
5132 Globals.iminreceivefile = 0;
5134 Globals.bMapUntrustedToDomain = false;
5137 /*******************************************************************
5138 Convenience routine to grab string parameters into temporary memory
5139 and run standard_sub_basic on them. The buffers can be written to by
5140 callers without affecting the source string.
5141 ********************************************************************/
5143 static char *lp_string(const char *s)
5145 char *ret;
5146 TALLOC_CTX *ctx = talloc_tos();
5148 /* The follow debug is useful for tracking down memory problems
5149 especially if you have an inner loop that is calling a lp_*()
5150 function that returns a string. Perhaps this debug should be
5151 present all the time? */
5153 #if 0
5154 DEBUG(10, ("lp_string(%s)\n", s));
5155 #endif
5156 if (!s) {
5157 return NULL;
5160 ret = talloc_sub_basic(ctx,
5161 get_current_username(),
5162 current_user_info.domain,
5164 if (trim_char(ret, '\"', '\"')) {
5165 if (strchr(ret,'\"') != NULL) {
5166 TALLOC_FREE(ret);
5167 ret = talloc_sub_basic(ctx,
5168 get_current_username(),
5169 current_user_info.domain,
5173 return ret;
5177 In this section all the functions that are used to access the
5178 parameters from the rest of the program are defined
5181 #define FN_GLOBAL_STRING(fn_name,ptr) \
5182 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5183 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5184 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5185 #define FN_GLOBAL_LIST(fn_name,ptr) \
5186 const char **fn_name(void) {return(*(const char ***)(ptr));}
5187 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5188 bool fn_name(void) {return(*(bool *)(ptr));}
5189 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5190 char fn_name(void) {return(*(char *)(ptr));}
5191 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5192 int fn_name(void) {return(*(int *)(ptr));}
5194 #define FN_LOCAL_STRING(fn_name,val) \
5195 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5196 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5197 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5198 #define FN_LOCAL_LIST(fn_name,val) \
5199 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5200 #define FN_LOCAL_BOOL(fn_name,val) \
5201 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5202 #define FN_LOCAL_INTEGER(fn_name,val) \
5203 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5205 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5206 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5207 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5208 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5209 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5210 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));}
5211 #define FN_LOCAL_CHAR(fn_name,val) \
5212 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5214 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5215 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5216 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5217 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5218 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5219 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5220 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5221 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5222 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5223 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5224 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5225 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5226 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5227 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5228 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5229 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5230 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5231 * build process or in smb.conf, we use that value. Otherwise they
5232 * default to the value of lp_lockdir(). */
5233 char *lp_statedir(void) {
5234 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5235 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5236 return(lp_string(*(char **)(&Globals.szStateDir) ?
5237 *(char **)(&Globals.szStateDir) : ""));
5238 else
5239 return(lp_string(*(char **)(&Globals.szLockDir) ?
5240 *(char **)(&Globals.szLockDir) : ""));
5242 char *lp_cachedir(void) {
5243 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5244 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5245 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5246 *(char **)(&Globals.szCacheDir) : ""));
5247 else
5248 return(lp_string(*(char **)(&Globals.szLockDir) ?
5249 *(char **)(&Globals.szLockDir) : ""));
5251 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5252 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5253 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5254 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5255 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5256 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5257 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5258 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5259 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5260 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5261 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5262 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5263 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5264 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5265 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5266 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5267 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5268 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5269 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5270 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5271 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5272 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5273 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5274 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5275 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5276 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5277 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5278 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5279 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5280 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5281 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5282 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5283 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5284 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5285 * lp_passdb_backend() should be replace by the this macro again after
5286 * some releases.
5287 * */
5288 const char *lp_passdb_backend(void)
5290 char *delim, *quote;
5292 delim = strchr( Globals.szPassdbBackend, ' ');
5293 /* no space at all */
5294 if (delim == NULL) {
5295 goto out;
5298 quote = strchr(Globals.szPassdbBackend, '"');
5299 /* no quote char or non in the first part */
5300 if (quote == NULL || quote > delim) {
5301 *delim = '\0';
5302 goto warn;
5305 quote = strchr(quote+1, '"');
5306 if (quote == NULL) {
5307 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5308 goto out;
5309 } else if (*(quote+1) == '\0') {
5310 /* space, fitting quote char, and one backend only */
5311 goto out;
5312 } else {
5313 /* terminate string after the fitting quote char */
5314 *(quote+1) = '\0';
5317 warn:
5318 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5319 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5320 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5321 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5323 out:
5324 return Globals.szPassdbBackend;
5326 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5327 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5328 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5329 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5330 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5332 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5333 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5334 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5335 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5336 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5337 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5339 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5341 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5342 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5343 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5345 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5347 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5348 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5349 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5350 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5351 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5352 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5353 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5354 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5355 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5356 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5357 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5358 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5359 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5360 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5361 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5363 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5364 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5365 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5366 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5367 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5368 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5370 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5371 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5372 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5373 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5374 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5375 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5376 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5377 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5378 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5379 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5380 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5381 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5382 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5383 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5384 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5385 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5386 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5387 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5389 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5391 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5392 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5393 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5394 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5395 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5396 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5397 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5398 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5399 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5400 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5401 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5402 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5403 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5404 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5405 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5406 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5407 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5408 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5409 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5410 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5411 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5412 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5413 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5414 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5415 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5416 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5417 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5418 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5419 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5420 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5421 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5422 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5423 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5424 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5425 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5426 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5427 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5428 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5429 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5430 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5431 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5432 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5433 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5434 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5435 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5436 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5437 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5438 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5439 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5440 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5441 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5442 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5443 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5444 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5445 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5446 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5447 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5448 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5449 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5450 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5451 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5452 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5453 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5454 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5455 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5456 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5457 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5458 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5459 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5460 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5461 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5462 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5463 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5464 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5465 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5466 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5467 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5468 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5469 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5470 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5471 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5472 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5473 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5474 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5475 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5476 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5477 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5478 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5479 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5480 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5481 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5482 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5483 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5484 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5485 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5486 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5487 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5488 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5489 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5490 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5492 FN_LOCAL_STRING(lp_preexec, szPreExec)
5493 FN_LOCAL_STRING(lp_postexec, szPostExec)
5494 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5495 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5496 FN_LOCAL_STRING(lp_servicename, szService)
5497 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5498 FN_LOCAL_STRING(lp_pathname, szPath)
5499 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5500 FN_LOCAL_STRING(lp_username, szUsername)
5501 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5502 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5503 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5504 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5505 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5506 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5507 int lp_cups_encrypt(void)
5509 #ifdef HAVE_HTTPCONNECTENCRYPT
5510 switch (Globals.CupsEncrypt) {
5511 case Auto:
5512 Globals.CupsEncrypt = HTTP_ENCRYPT_REQUIRED;
5513 break;
5514 case True:
5515 Globals.CupsEncrypt = HTTP_ENCRYPT_ALWAYS;
5516 break;
5517 case False:
5518 Globals.CupsEncrypt = HTTP_ENCRYPT_NEVER;
5519 break;
5521 #endif
5522 return Globals.CupsEncrypt;
5524 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5525 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5526 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5527 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5528 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5529 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5530 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5531 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5532 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5533 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5534 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5535 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5536 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5537 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5538 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5539 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5540 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5541 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5542 FN_LOCAL_STRING(lp_comment, comment)
5543 FN_LOCAL_STRING(lp_force_user, force_user)
5544 FN_LOCAL_STRING(lp_force_group, force_group)
5545 FN_LOCAL_LIST(lp_readlist, readlist)
5546 FN_LOCAL_LIST(lp_writelist, writelist)
5547 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5548 FN_LOCAL_STRING(lp_fstype, fstype)
5549 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5550 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5551 static FN_LOCAL_STRING(lp_volume, volume)
5552 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5553 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5554 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5555 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5556 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5557 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5558 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5559 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5560 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5561 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5562 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5563 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5564 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5565 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5566 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5567 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5568 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5569 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5570 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5571 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5572 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5573 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5574 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5575 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5576 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5577 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5578 FN_LOCAL_BOOL(lp_store_create_time, bStoreCreateTime)
5579 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5580 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5581 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5582 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5583 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5584 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5585 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5586 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5587 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5588 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5589 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
5590 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5591 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5592 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5593 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5594 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5595 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5596 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5597 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5598 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5599 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5600 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5601 FN_GLOBAL_BOOL(lp_fake_dir_create_times, &Globals.bFakeDirCreateTimes)
5602 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5603 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5604 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5605 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5606 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5607 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5608 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5609 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5610 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5611 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5612 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5613 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5614 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5615 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5616 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5617 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5618 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5619 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5620 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5621 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5622 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5623 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5624 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5625 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5626 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5627 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5628 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5629 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5630 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5631 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5632 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5633 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5634 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5635 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5636 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5637 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5638 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5639 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5640 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5641 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5642 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5643 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5644 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5645 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5646 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5647 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5648 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5649 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5650 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5651 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5653 /* local prototypes */
5655 static int map_parameter(const char *pszParmName);
5656 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5657 static const char *get_boolean(bool bool_value);
5658 static int getservicebyname(const char *pszServiceName,
5659 struct service *pserviceDest);
5660 static void copy_service(struct service *pserviceDest,
5661 struct service *pserviceSource,
5662 struct bitmap *pcopymapDest);
5663 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5664 void *userdata);
5665 static bool do_section(const char *pszSectionName, void *userdata);
5666 static void init_copymap(struct service *pservice);
5667 static bool hash_a_service(const char *name, int number);
5668 static void free_service_byindex(int iService);
5669 static void free_param_opts(struct param_opt_struct **popts);
5670 static char * canonicalize_servicename(const char *name);
5671 static void show_parameter(int parmIndex);
5672 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5675 * This is a helper function for parametrical options support. It returns a
5676 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5677 * parametrical functions are quite simple
5679 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5680 const char *option)
5682 bool global_section = False;
5683 char* param_key;
5684 struct param_opt_struct *data;
5686 if (snum >= iNumServices) return NULL;
5688 if (snum < 0) {
5689 data = Globals.param_opt;
5690 global_section = True;
5691 } else {
5692 data = ServicePtrs[snum]->param_opt;
5695 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5696 DEBUG(0,("asprintf failed!\n"));
5697 return NULL;
5700 while (data) {
5701 if (strwicmp(data->key, param_key) == 0) {
5702 string_free(&param_key);
5703 return data;
5705 data = data->next;
5708 if (!global_section) {
5709 /* Try to fetch the same option but from globals */
5710 /* but only if we are not already working with Globals */
5711 data = Globals.param_opt;
5712 while (data) {
5713 if (strwicmp(data->key, param_key) == 0) {
5714 string_free(&param_key);
5715 return data;
5717 data = data->next;
5721 string_free(&param_key);
5723 return NULL;
5727 #define MISSING_PARAMETER(name) \
5728 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5730 /*******************************************************************
5731 convenience routine to return int parameters.
5732 ********************************************************************/
5733 static int lp_int(const char *s)
5736 if (!s || !*s) {
5737 MISSING_PARAMETER(lp_int);
5738 return (-1);
5741 return (int)strtol(s, NULL, 0);
5744 /*******************************************************************
5745 convenience routine to return unsigned long parameters.
5746 ********************************************************************/
5747 static unsigned long lp_ulong(const char *s)
5750 if (!s || !*s) {
5751 MISSING_PARAMETER(lp_ulong);
5752 return (0);
5755 return strtoul(s, NULL, 0);
5758 /*******************************************************************
5759 convenience routine to return boolean parameters.
5760 ********************************************************************/
5761 static bool lp_bool(const char *s)
5763 bool ret = False;
5765 if (!s || !*s) {
5766 MISSING_PARAMETER(lp_bool);
5767 return False;
5770 if (!set_boolean(s, &ret)) {
5771 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5772 return False;
5775 return ret;
5778 /*******************************************************************
5779 convenience routine to return enum parameters.
5780 ********************************************************************/
5781 static int lp_enum(const char *s,const struct enum_list *_enum)
5783 int i;
5785 if (!s || !*s || !_enum) {
5786 MISSING_PARAMETER(lp_enum);
5787 return (-1);
5790 for (i=0; _enum[i].name; i++) {
5791 if (strequal(_enum[i].name,s))
5792 return _enum[i].value;
5795 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5796 return (-1);
5799 #undef MISSING_PARAMETER
5801 /* DO NOT USE lp_parm_string ANYMORE!!!!
5802 * use lp_parm_const_string or lp_parm_talloc_string
5804 * lp_parm_string is only used to let old modules find this symbol
5806 #undef lp_parm_string
5807 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5808 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5810 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5813 /* Return parametric option from a given service. Type is a part of option before ':' */
5814 /* Parametric option has following syntax: 'Type: option = value' */
5815 /* the returned value is talloced on the talloc_tos() */
5816 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5818 struct param_opt_struct *data = get_parametrics(snum, type, option);
5820 if (data == NULL||data->value==NULL) {
5821 if (def) {
5822 return lp_string(def);
5823 } else {
5824 return NULL;
5828 return lp_string(data->value);
5831 /* Return parametric option from a given service. Type is a part of option before ':' */
5832 /* Parametric option has following syntax: 'Type: option = value' */
5833 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5835 struct param_opt_struct *data = get_parametrics(snum, type, option);
5837 if (data == NULL||data->value==NULL)
5838 return def;
5840 return data->value;
5843 /* Return parametric option from a given service. Type is a part of option before ':' */
5844 /* Parametric option has following syntax: 'Type: option = value' */
5846 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5848 struct param_opt_struct *data = get_parametrics(snum, type, option);
5850 if (data == NULL||data->value==NULL)
5851 return (const char **)def;
5853 if (data->list==NULL) {
5854 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
5857 return (const char **)data->list;
5860 /* Return parametric option from a given service. Type is a part of option before ':' */
5861 /* Parametric option has following syntax: 'Type: option = value' */
5863 int lp_parm_int(int snum, const char *type, const char *option, int def)
5865 struct param_opt_struct *data = get_parametrics(snum, type, option);
5867 if (data && data->value && *data->value)
5868 return lp_int(data->value);
5870 return def;
5873 /* Return parametric option from a given service. Type is a part of option before ':' */
5874 /* Parametric option has following syntax: 'Type: option = value' */
5876 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5878 struct param_opt_struct *data = get_parametrics(snum, type, option);
5880 if (data && data->value && *data->value)
5881 return lp_ulong(data->value);
5883 return def;
5886 /* Return parametric option from a given service. Type is a part of option before ':' */
5887 /* Parametric option has following syntax: 'Type: option = value' */
5889 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5891 struct param_opt_struct *data = get_parametrics(snum, type, option);
5893 if (data && data->value && *data->value)
5894 return lp_bool(data->value);
5896 return def;
5899 /* Return parametric option from a given service. Type is a part of option before ':' */
5900 /* Parametric option has following syntax: 'Type: option = value' */
5902 int lp_parm_enum(int snum, const char *type, const char *option,
5903 const struct enum_list *_enum, int def)
5905 struct param_opt_struct *data = get_parametrics(snum, type, option);
5907 if (data && data->value && *data->value && _enum)
5908 return lp_enum(data->value, _enum);
5910 return def;
5914 /***************************************************************************
5915 Initialise a service to the defaults.
5916 ***************************************************************************/
5918 static void init_service(struct service *pservice)
5920 memset((char *)pservice, '\0', sizeof(struct service));
5921 copy_service(pservice, &sDefault, NULL);
5926 * free a param_opts structure.
5927 * param_opts handling should be moved to talloc;
5928 * then this whole functions reduces to a TALLOC_FREE().
5931 static void free_param_opts(struct param_opt_struct **popts)
5933 struct param_opt_struct *opt, *next_opt;
5935 if (popts == NULL) {
5936 return;
5939 if (*popts != NULL) {
5940 DEBUG(5, ("Freeing parametrics:\n"));
5942 opt = *popts;
5943 while (opt != NULL) {
5944 string_free(&opt->key);
5945 string_free(&opt->value);
5946 TALLOC_FREE(opt->list);
5947 next_opt = opt->next;
5948 SAFE_FREE(opt);
5949 opt = next_opt;
5951 *popts = NULL;
5954 /***************************************************************************
5955 Free the dynamically allocated parts of a service struct.
5956 ***************************************************************************/
5958 static void free_service(struct service *pservice)
5960 if (!pservice)
5961 return;
5963 if (pservice->szService)
5964 DEBUG(5, ("free_service: Freeing service %s\n",
5965 pservice->szService));
5967 free_parameters(pservice);
5969 string_free(&pservice->szService);
5970 bitmap_free(pservice->copymap);
5972 free_param_opts(&pservice->param_opt);
5974 ZERO_STRUCTP(pservice);
5978 /***************************************************************************
5979 remove a service indexed in the ServicePtrs array from the ServiceHash
5980 and free the dynamically allocated parts
5981 ***************************************************************************/
5983 static void free_service_byindex(int idx)
5985 if ( !LP_SNUM_OK(idx) )
5986 return;
5988 ServicePtrs[idx]->valid = False;
5989 invalid_services[num_invalid_services++] = idx;
5991 /* we have to cleanup the hash record */
5993 if (ServicePtrs[idx]->szService) {
5994 char *canon_name = canonicalize_servicename(
5995 ServicePtrs[idx]->szService );
5997 dbwrap_delete_bystring(ServiceHash, canon_name );
5998 TALLOC_FREE(canon_name);
6001 free_service(ServicePtrs[idx]);
6004 /***************************************************************************
6005 Add a new service to the services array initialising it with the given
6006 service.
6007 ***************************************************************************/
6009 static int add_a_service(const struct service *pservice, const char *name)
6011 int i;
6012 struct service tservice;
6013 int num_to_alloc = iNumServices + 1;
6015 tservice = *pservice;
6017 /* it might already exist */
6018 if (name) {
6019 i = getservicebyname(name, NULL);
6020 if (i >= 0) {
6021 /* Clean all parametric options for service */
6022 /* They will be added during parsing again */
6023 free_param_opts(&ServicePtrs[i]->param_opt);
6024 return (i);
6028 /* find an invalid one */
6029 i = iNumServices;
6030 if (num_invalid_services > 0) {
6031 i = invalid_services[--num_invalid_services];
6034 /* if not, then create one */
6035 if (i == iNumServices) {
6036 struct service **tsp;
6037 int *tinvalid;
6039 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
6040 if (tsp == NULL) {
6041 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
6042 return (-1);
6044 ServicePtrs = tsp;
6045 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
6046 if (!ServicePtrs[iNumServices]) {
6047 DEBUG(0,("add_a_service: out of memory!\n"));
6048 return (-1);
6050 iNumServices++;
6052 /* enlarge invalid_services here for now... */
6053 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6054 num_to_alloc);
6055 if (tinvalid == NULL) {
6056 DEBUG(0,("add_a_service: failed to enlarge "
6057 "invalid_services!\n"));
6058 return (-1);
6060 invalid_services = tinvalid;
6061 } else {
6062 free_service_byindex(i);
6065 ServicePtrs[i]->valid = True;
6067 init_service(ServicePtrs[i]);
6068 copy_service(ServicePtrs[i], &tservice, NULL);
6069 if (name)
6070 string_set(&ServicePtrs[i]->szService, name);
6072 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6073 i, ServicePtrs[i]->szService));
6075 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6076 return (-1);
6079 return (i);
6082 /***************************************************************************
6083 Convert a string to uppercase and remove whitespaces.
6084 ***************************************************************************/
6086 static char *canonicalize_servicename(const char *src)
6088 char *result;
6090 if ( !src ) {
6091 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6092 return NULL;
6095 result = talloc_strdup(talloc_tos(), src);
6096 SMB_ASSERT(result != NULL);
6098 strlower_m(result);
6099 return result;
6102 /***************************************************************************
6103 Add a name/index pair for the services array to the hash table.
6104 ***************************************************************************/
6106 static bool hash_a_service(const char *name, int idx)
6108 char *canon_name;
6110 if ( !ServiceHash ) {
6111 DEBUG(10,("hash_a_service: creating servicehash\n"));
6112 ServiceHash = db_open_rbt(NULL);
6113 if ( !ServiceHash ) {
6114 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6115 return False;
6119 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6120 idx, name));
6122 canon_name = canonicalize_servicename( name );
6124 dbwrap_store_bystring(ServiceHash, canon_name,
6125 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6126 TDB_REPLACE);
6128 TALLOC_FREE(canon_name);
6130 return True;
6133 /***************************************************************************
6134 Add a new home service, with the specified home directory, defaults coming
6135 from service ifrom.
6136 ***************************************************************************/
6138 bool lp_add_home(const char *pszHomename, int iDefaultService,
6139 const char *user, const char *pszHomedir)
6141 int i;
6143 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6145 if (i < 0)
6146 return (False);
6148 if (!(*(ServicePtrs[iDefaultService]->szPath))
6149 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6150 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6153 if (!(*(ServicePtrs[i]->comment))) {
6154 char *comment = NULL;
6155 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6156 return false;
6158 string_set(&ServicePtrs[i]->comment, comment);
6159 SAFE_FREE(comment);
6162 /* set the browseable flag from the global default */
6164 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6165 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6167 ServicePtrs[i]->autoloaded = True;
6169 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6170 user, ServicePtrs[i]->szPath ));
6172 return (True);
6175 /***************************************************************************
6176 Add a new service, based on an old one.
6177 ***************************************************************************/
6179 int lp_add_service(const char *pszService, int iDefaultService)
6181 if (iDefaultService < 0) {
6182 return add_a_service(&sDefault, pszService);
6185 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6188 /***************************************************************************
6189 Add the IPC service.
6190 ***************************************************************************/
6192 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6194 char *comment = NULL;
6195 int i = add_a_service(&sDefault, ipc_name);
6197 if (i < 0)
6198 return (False);
6200 if (asprintf(&comment, "IPC Service (%s)",
6201 Globals.szServerString) < 0) {
6202 return (False);
6205 string_set(&ServicePtrs[i]->szPath, tmpdir());
6206 string_set(&ServicePtrs[i]->szUsername, "");
6207 string_set(&ServicePtrs[i]->comment, comment);
6208 string_set(&ServicePtrs[i]->fstype, "IPC");
6209 ServicePtrs[i]->iMaxConnections = 0;
6210 ServicePtrs[i]->bAvailable = True;
6211 ServicePtrs[i]->bRead_only = True;
6212 ServicePtrs[i]->bGuest_only = False;
6213 ServicePtrs[i]->bAdministrative_share = True;
6214 ServicePtrs[i]->bGuest_ok = guest_ok;
6215 ServicePtrs[i]->bPrint_ok = False;
6216 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6218 DEBUG(3, ("adding IPC service\n"));
6220 SAFE_FREE(comment);
6221 return (True);
6224 /***************************************************************************
6225 Add a new printer service, with defaults coming from service iFrom.
6226 ***************************************************************************/
6228 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6230 const char *comment = "From Printcap";
6231 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6233 if (i < 0)
6234 return (False);
6236 /* note that we do NOT default the availability flag to True - */
6237 /* we take it from the default service passed. This allows all */
6238 /* dynamic printers to be disabled by disabling the [printers] */
6239 /* entry (if/when the 'available' keyword is implemented!). */
6241 /* the printer name is set to the service name. */
6242 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6243 string_set(&ServicePtrs[i]->comment, comment);
6245 /* set the browseable flag from the gloabl default */
6246 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6248 /* Printers cannot be read_only. */
6249 ServicePtrs[i]->bRead_only = False;
6250 /* No share modes on printer services. */
6251 ServicePtrs[i]->bShareModes = False;
6252 /* No oplocks on printer services. */
6253 ServicePtrs[i]->bOpLocks = False;
6254 /* Printer services must be printable. */
6255 ServicePtrs[i]->bPrint_ok = True;
6257 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6259 return (True);
6263 /***************************************************************************
6264 Check whether the given parameter name is valid.
6265 Parametric options (names containing a colon) are considered valid.
6266 ***************************************************************************/
6268 bool lp_parameter_is_valid(const char *pszParmName)
6270 return ((map_parameter(pszParmName) != -1) ||
6271 (strchr(pszParmName, ':') != NULL));
6274 /***************************************************************************
6275 Check whether the given name is the name of a global parameter.
6276 Returns True for strings belonging to parameters of class
6277 P_GLOBAL, False for all other strings, also for parametric options
6278 and strings not belonging to any option.
6279 ***************************************************************************/
6281 bool lp_parameter_is_global(const char *pszParmName)
6283 int num = map_parameter(pszParmName);
6285 if (num >= 0) {
6286 return (parm_table[num].p_class == P_GLOBAL);
6289 return False;
6292 /**************************************************************************
6293 Check whether the given name is the canonical name of a parameter.
6294 Returns False if it is not a valid parameter Name.
6295 For parametric options, True is returned.
6296 **************************************************************************/
6298 bool lp_parameter_is_canonical(const char *parm_name)
6300 if (!lp_parameter_is_valid(parm_name)) {
6301 return False;
6304 return (map_parameter(parm_name) ==
6305 map_parameter_canonical(parm_name, NULL));
6308 /**************************************************************************
6309 Determine the canonical name for a parameter.
6310 Indicate when it is an inverse (boolean) synonym instead of a
6311 "usual" synonym.
6312 **************************************************************************/
6314 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6315 bool *inverse)
6317 int num;
6319 if (!lp_parameter_is_valid(parm_name)) {
6320 *canon_parm = NULL;
6321 return False;
6324 num = map_parameter_canonical(parm_name, inverse);
6325 if (num < 0) {
6326 /* parametric option */
6327 *canon_parm = parm_name;
6328 } else {
6329 *canon_parm = parm_table[num].label;
6332 return True;
6336 /**************************************************************************
6337 Determine the canonical name for a parameter.
6338 Turn the value given into the inverse boolean expression when
6339 the synonym is an invers boolean synonym.
6341 Return True if parm_name is a valid parameter name and
6342 in case it is an invers boolean synonym, if the val string could
6343 successfully be converted to the reverse bool.
6344 Return false in all other cases.
6345 **************************************************************************/
6347 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6348 const char *val,
6349 const char **canon_parm,
6350 const char **canon_val)
6352 int num;
6353 bool inverse;
6355 if (!lp_parameter_is_valid(parm_name)) {
6356 *canon_parm = NULL;
6357 *canon_val = NULL;
6358 return False;
6361 num = map_parameter_canonical(parm_name, &inverse);
6362 if (num < 0) {
6363 /* parametric option */
6364 *canon_parm = parm_name;
6365 *canon_val = val;
6366 } else {
6367 *canon_parm = parm_table[num].label;
6368 if (inverse) {
6369 if (!lp_invert_boolean(val, canon_val)) {
6370 *canon_val = NULL;
6371 return False;
6373 } else {
6374 *canon_val = val;
6378 return True;
6381 /***************************************************************************
6382 Map a parameter's string representation to something we can use.
6383 Returns False if the parameter string is not recognised, else TRUE.
6384 ***************************************************************************/
6386 static int map_parameter(const char *pszParmName)
6388 int iIndex;
6390 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6391 return (-1);
6393 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6394 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6395 return (iIndex);
6397 /* Warn only if it isn't parametric option */
6398 if (strchr(pszParmName, ':') == NULL)
6399 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6400 /* We do return 'fail' for parametric options as well because they are
6401 stored in different storage
6403 return (-1);
6406 /***************************************************************************
6407 Map a parameter's string representation to the index of the canonical
6408 form of the parameter (it might be a synonym).
6409 Returns -1 if the parameter string is not recognised.
6410 ***************************************************************************/
6412 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6414 int parm_num, canon_num;
6415 bool loc_inverse = False;
6417 parm_num = map_parameter(pszParmName);
6418 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6419 /* invalid, parametric or no canidate for synonyms ... */
6420 goto done;
6423 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6424 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6425 parm_num = canon_num;
6426 goto done;
6430 done:
6431 if (inverse != NULL) {
6432 *inverse = loc_inverse;
6434 return parm_num;
6437 /***************************************************************************
6438 return true if parameter number parm1 is a synonym of parameter
6439 number parm2 (parm2 being the principal name).
6440 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6441 False otherwise.
6442 ***************************************************************************/
6444 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6446 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6447 (parm_table[parm1].flags & FLAG_HIDE) &&
6448 !(parm_table[parm2].flags & FLAG_HIDE))
6450 if (inverse != NULL) {
6451 if ((parm_table[parm1].type == P_BOOLREV) &&
6452 (parm_table[parm2].type == P_BOOL))
6454 *inverse = True;
6455 } else {
6456 *inverse = False;
6459 return True;
6461 return False;
6464 /***************************************************************************
6465 Show one parameter's name, type, [values,] and flags.
6466 (helper functions for show_parameter_list)
6467 ***************************************************************************/
6469 static void show_parameter(int parmIndex)
6471 int enumIndex, flagIndex;
6472 int parmIndex2;
6473 bool hadFlag;
6474 bool hadSyn;
6475 bool inverse;
6476 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6477 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6478 "P_ENUM", "P_SEP"};
6479 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6480 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6481 FLAG_HIDE, FLAG_DOS_STRING};
6482 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6483 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6484 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6486 printf("%s=%s", parm_table[parmIndex].label,
6487 type[parm_table[parmIndex].type]);
6488 if (parm_table[parmIndex].type == P_ENUM) {
6489 printf(",");
6490 for (enumIndex=0;
6491 parm_table[parmIndex].enum_list[enumIndex].name;
6492 enumIndex++)
6494 printf("%s%s",
6495 enumIndex ? "|" : "",
6496 parm_table[parmIndex].enum_list[enumIndex].name);
6499 printf(",");
6500 hadFlag = False;
6501 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6502 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6503 printf("%s%s",
6504 hadFlag ? "|" : "",
6505 flag_names[flagIndex]);
6506 hadFlag = True;
6510 /* output synonyms */
6511 hadSyn = False;
6512 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6513 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6514 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6515 parm_table[parmIndex2].label);
6516 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6517 if (!hadSyn) {
6518 printf(" (synonyms: ");
6519 hadSyn = True;
6520 } else {
6521 printf(", ");
6523 printf("%s%s", parm_table[parmIndex2].label,
6524 inverse ? "[i]" : "");
6527 if (hadSyn) {
6528 printf(")");
6531 printf("\n");
6534 /***************************************************************************
6535 Show all parameter's name, type, [values,] and flags.
6536 ***************************************************************************/
6538 void show_parameter_list(void)
6540 int classIndex, parmIndex;
6541 const char *section_names[] = { "local", "global", NULL};
6543 for (classIndex=0; section_names[classIndex]; classIndex++) {
6544 printf("[%s]\n", section_names[classIndex]);
6545 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6546 if (parm_table[parmIndex].p_class == classIndex) {
6547 show_parameter(parmIndex);
6553 /***************************************************************************
6554 Check if a given string correctly represents a boolean value.
6555 ***************************************************************************/
6557 bool lp_string_is_valid_boolean(const char *parm_value)
6559 return set_boolean(parm_value, NULL);
6562 /***************************************************************************
6563 Get the standard string representation of a boolean value ("yes" or "no")
6564 ***************************************************************************/
6566 static const char *get_boolean(bool bool_value)
6568 static const char *yes_str = "yes";
6569 static const char *no_str = "no";
6571 return (bool_value ? yes_str : no_str);
6574 /***************************************************************************
6575 Provide the string of the negated boolean value associated to the boolean
6576 given as a string. Returns False if the passed string does not correctly
6577 represent a boolean.
6578 ***************************************************************************/
6580 bool lp_invert_boolean(const char *str, const char **inverse_str)
6582 bool val;
6584 if (!set_boolean(str, &val)) {
6585 return False;
6588 *inverse_str = get_boolean(!val);
6589 return True;
6592 /***************************************************************************
6593 Provide the canonical string representation of a boolean value given
6594 as a string. Return True on success, False if the string given does
6595 not correctly represent a boolean.
6596 ***************************************************************************/
6598 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6600 bool val;
6602 if (!set_boolean(str, &val)) {
6603 return False;
6606 *canon_str = get_boolean(val);
6607 return True;
6610 /***************************************************************************
6611 Find a service by name. Otherwise works like get_service.
6612 ***************************************************************************/
6614 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6616 int iService = -1;
6617 char *canon_name;
6618 TDB_DATA data;
6620 if (ServiceHash == NULL) {
6621 return -1;
6624 canon_name = canonicalize_servicename(pszServiceName);
6626 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6628 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6629 iService = *(int *)data.dptr;
6632 TALLOC_FREE(canon_name);
6634 if ((iService != -1) && (LP_SNUM_OK(iService))
6635 && (pserviceDest != NULL)) {
6636 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6639 return (iService);
6642 /***************************************************************************
6643 Copy a service structure to another.
6644 If pcopymapDest is NULL then copy all fields
6645 ***************************************************************************/
6648 * Add a parametric option to a param_opt_struct,
6649 * replacing old value, if already present.
6651 static void set_param_opt(struct param_opt_struct **opt_list,
6652 const char *opt_name,
6653 const char *opt_value)
6655 struct param_opt_struct *new_opt, *opt;
6656 bool not_added;
6658 if (opt_list == NULL) {
6659 return;
6662 opt = *opt_list;
6663 not_added = true;
6665 /* Traverse destination */
6666 while (opt) {
6667 /* If we already have same option, override it */
6668 if (strwicmp(opt->key, opt_name) == 0) {
6669 string_free(&opt->value);
6670 TALLOC_FREE(opt->list);
6671 opt->value = SMB_STRDUP(opt_value);
6672 not_added = false;
6673 break;
6675 opt = opt->next;
6677 if (not_added) {
6678 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6679 new_opt->key = SMB_STRDUP(opt_name);
6680 new_opt->value = SMB_STRDUP(opt_value);
6681 new_opt->list = NULL;
6682 DLIST_ADD(*opt_list, new_opt);
6686 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6687 struct bitmap *pcopymapDest)
6689 int i;
6690 bool bcopyall = (pcopymapDest == NULL);
6691 struct param_opt_struct *data;
6693 for (i = 0; parm_table[i].label; i++)
6694 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6695 (bcopyall || bitmap_query(pcopymapDest,i))) {
6696 void *def_ptr = parm_table[i].ptr;
6697 void *src_ptr =
6698 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6699 &sDefault);
6700 void *dest_ptr =
6701 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6702 &sDefault);
6704 switch (parm_table[i].type) {
6705 case P_BOOL:
6706 case P_BOOLREV:
6707 *(bool *)dest_ptr = *(bool *)src_ptr;
6708 break;
6710 case P_INTEGER:
6711 case P_ENUM:
6712 case P_OCTAL:
6713 *(int *)dest_ptr = *(int *)src_ptr;
6714 break;
6716 case P_CHAR:
6717 *(char *)dest_ptr = *(char *)src_ptr;
6718 break;
6720 case P_STRING:
6721 string_set((char **)dest_ptr,
6722 *(char **)src_ptr);
6723 break;
6725 case P_USTRING:
6726 string_set((char **)dest_ptr,
6727 *(char **)src_ptr);
6728 strupper_m(*(char **)dest_ptr);
6729 break;
6730 case P_LIST:
6731 TALLOC_FREE(*((char ***)dest_ptr));
6732 *((char ***)dest_ptr) = str_list_copy(NULL,
6733 *(const char ***)src_ptr);
6734 break;
6735 default:
6736 break;
6740 if (bcopyall) {
6741 init_copymap(pserviceDest);
6742 if (pserviceSource->copymap)
6743 bitmap_copy(pserviceDest->copymap,
6744 pserviceSource->copymap);
6747 data = pserviceSource->param_opt;
6748 while (data) {
6749 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6750 data = data->next;
6754 /***************************************************************************
6755 Check a service for consistency. Return False if the service is in any way
6756 incomplete or faulty, else True.
6757 ***************************************************************************/
6759 bool service_ok(int iService)
6761 bool bRetval;
6763 bRetval = True;
6764 if (ServicePtrs[iService]->szService[0] == '\0') {
6765 DEBUG(0, ("The following message indicates an internal error:\n"));
6766 DEBUG(0, ("No service name in service entry.\n"));
6767 bRetval = False;
6770 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6771 /* I can't see why you'd want a non-printable printer service... */
6772 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6773 if (!ServicePtrs[iService]->bPrint_ok) {
6774 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6775 ServicePtrs[iService]->szService));
6776 ServicePtrs[iService]->bPrint_ok = True;
6778 /* [printers] service must also be non-browsable. */
6779 if (ServicePtrs[iService]->bBrowseable)
6780 ServicePtrs[iService]->bBrowseable = False;
6783 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6784 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6785 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6787 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6788 ServicePtrs[iService]->szService));
6789 ServicePtrs[iService]->bAvailable = False;
6792 /* If a service is flagged unavailable, log the fact at level 1. */
6793 if (!ServicePtrs[iService]->bAvailable)
6794 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6795 ServicePtrs[iService]->szService));
6797 return (bRetval);
6800 static struct smbconf_ctx *lp_smbconf_ctx(void)
6802 WERROR werr;
6803 static struct smbconf_ctx *conf_ctx = NULL;
6805 if (conf_ctx == NULL) {
6806 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6807 if (!W_ERROR_IS_OK(werr)) {
6808 DEBUG(1, ("error initializing registry configuration: "
6809 "%s\n", win_errstr(werr)));
6810 conf_ctx = NULL;
6814 return conf_ctx;
6817 static bool process_smbconf_service(struct smbconf_service *service)
6819 uint32_t count;
6820 bool ret;
6822 if (service == NULL) {
6823 return false;
6826 ret = do_section(service->name, NULL);
6827 if (ret != true) {
6828 return false;
6830 for (count = 0; count < service->num_params; count++) {
6831 ret = do_parameter(service->param_names[count],
6832 service->param_values[count],
6833 NULL);
6834 if (ret != true) {
6835 return false;
6838 if (iServiceIndex >= 0) {
6839 return service_ok(iServiceIndex);
6841 return true;
6845 * load a service from registry and activate it
6847 bool process_registry_service(const char *service_name)
6849 WERROR werr;
6850 struct smbconf_service *service = NULL;
6851 TALLOC_CTX *mem_ctx = talloc_stackframe();
6852 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6853 bool ret = false;
6855 if (conf_ctx == NULL) {
6856 goto done;
6859 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6861 if (!smbconf_share_exists(conf_ctx, service_name)) {
6863 * Registry does not contain data for this service (yet),
6864 * but make sure lp_load doesn't return false.
6866 ret = true;
6867 goto done;
6870 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6871 if (!W_ERROR_IS_OK(werr)) {
6872 goto done;
6875 ret = process_smbconf_service(service);
6876 if (!ret) {
6877 goto done;
6880 /* store the csn */
6881 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6883 done:
6884 TALLOC_FREE(mem_ctx);
6885 return ret;
6889 * process_registry_globals
6891 static bool process_registry_globals(void)
6893 bool ret;
6895 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6897 ret = do_parameter("registry shares", "yes", NULL);
6898 if (!ret) {
6899 return ret;
6902 return process_registry_service(GLOBAL_NAME);
6905 bool process_registry_shares(void)
6907 WERROR werr;
6908 uint32_t count;
6909 struct smbconf_service **service = NULL;
6910 uint32_t num_shares = 0;
6911 TALLOC_CTX *mem_ctx = talloc_stackframe();
6912 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6913 bool ret = false;
6915 if (conf_ctx == NULL) {
6916 goto done;
6919 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6920 if (!W_ERROR_IS_OK(werr)) {
6921 goto done;
6924 ret = true;
6926 for (count = 0; count < num_shares; count++) {
6927 if (strequal(service[count]->name, GLOBAL_NAME)) {
6928 continue;
6930 ret = process_smbconf_service(service[count]);
6931 if (!ret) {
6932 goto done;
6936 /* store the csn */
6937 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6939 done:
6940 TALLOC_FREE(mem_ctx);
6941 return ret;
6944 #define MAX_INCLUDE_DEPTH 100
6946 static uint8_t include_depth;
6948 static struct file_lists {
6949 struct file_lists *next;
6950 char *name;
6951 char *subfname;
6952 time_t modtime;
6953 } *file_lists = NULL;
6955 /*******************************************************************
6956 Keep a linked list of all config files so we know when one has changed
6957 it's date and needs to be reloaded.
6958 ********************************************************************/
6960 static void add_to_file_list(const char *fname, const char *subfname)
6962 struct file_lists *f = file_lists;
6964 while (f) {
6965 if (f->name && !strcmp(f->name, fname))
6966 break;
6967 f = f->next;
6970 if (!f) {
6971 f = SMB_MALLOC_P(struct file_lists);
6972 if (!f)
6973 return;
6974 f->next = file_lists;
6975 f->name = SMB_STRDUP(fname);
6976 if (!f->name) {
6977 SAFE_FREE(f);
6978 return;
6980 f->subfname = SMB_STRDUP(subfname);
6981 if (!f->subfname) {
6982 SAFE_FREE(f);
6983 return;
6985 file_lists = f;
6986 f->modtime = file_modtime(subfname);
6987 } else {
6988 time_t t = file_modtime(subfname);
6989 if (t)
6990 f->modtime = t;
6995 * Free the file lists
6997 static void free_file_list(void)
6999 struct file_lists *f;
7000 struct file_lists *next;
7002 f = file_lists;
7003 while( f ) {
7004 next = f->next;
7005 SAFE_FREE( f->name );
7006 SAFE_FREE( f->subfname );
7007 SAFE_FREE( f );
7008 f = next;
7010 file_lists = NULL;
7015 * Utility function for outsiders to check if we're running on registry.
7017 bool lp_config_backend_is_registry(void)
7019 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
7023 * Utility function to check if the config backend is FILE.
7025 bool lp_config_backend_is_file(void)
7027 return (lp_config_backend() == CONFIG_BACKEND_FILE);
7030 /*******************************************************************
7031 Check if a config file has changed date.
7032 ********************************************************************/
7034 bool lp_file_list_changed(void)
7036 struct file_lists *f = file_lists;
7038 DEBUG(6, ("lp_file_list_changed()\n"));
7040 while (f) {
7041 char *n2 = NULL;
7042 time_t mod_time;
7044 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
7045 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
7047 if (conf_ctx == NULL) {
7048 return false;
7050 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7051 NULL))
7053 DEBUGADD(6, ("registry config changed\n"));
7054 return true;
7056 } else {
7057 n2 = alloc_sub_basic(get_current_username(),
7058 current_user_info.domain,
7059 f->name);
7060 if (!n2) {
7061 return false;
7063 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7064 f->name, n2, ctime(&f->modtime)));
7066 mod_time = file_modtime(n2);
7068 if (mod_time &&
7069 ((f->modtime != mod_time) ||
7070 (f->subfname == NULL) ||
7071 (strcmp(n2, f->subfname) != 0)))
7073 DEBUGADD(6,
7074 ("file %s modified: %s\n", n2,
7075 ctime(&mod_time)));
7076 f->modtime = mod_time;
7077 SAFE_FREE(f->subfname);
7078 f->subfname = n2; /* Passing ownership of
7079 return from alloc_sub_basic
7080 above. */
7081 return true;
7083 SAFE_FREE(n2);
7085 f = f->next;
7087 return (False);
7091 /***************************************************************************
7092 Run standard_sub_basic on netbios name... needed because global_myname
7093 is not accessed through any lp_ macro.
7094 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7095 ***************************************************************************/
7097 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7099 bool ret;
7100 char *netbios_name = alloc_sub_basic(get_current_username(),
7101 current_user_info.domain,
7102 pszParmValue);
7104 ret = set_global_myname(netbios_name);
7105 SAFE_FREE(netbios_name);
7106 string_set(&Globals.szNetbiosName,global_myname());
7108 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7109 global_myname()));
7111 return ret;
7114 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7116 if (strcmp(*ptr, pszParmValue) != 0) {
7117 string_set(ptr, pszParmValue);
7118 init_iconv();
7120 return True;
7125 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7127 bool ret;
7129 ret = set_global_myworkgroup(pszParmValue);
7130 string_set(&Globals.szWorkgroup,lp_workgroup());
7132 return ret;
7135 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7137 bool ret;
7139 ret = set_global_scope(pszParmValue);
7140 string_set(&Globals.szNetbiosScope,global_scope());
7142 return ret;
7145 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7147 TALLOC_FREE(Globals.szNetbiosAliases);
7148 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7149 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7152 /***************************************************************************
7153 Handle the include operation.
7154 ***************************************************************************/
7155 static bool bAllowIncludeRegistry = true;
7157 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7159 char *fname;
7161 if (include_depth >= MAX_INCLUDE_DEPTH) {
7162 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7163 include_depth));
7164 return false;
7167 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7168 if (!bAllowIncludeRegistry) {
7169 return true;
7171 if (bInGlobalSection) {
7172 bool ret;
7173 include_depth++;
7174 ret = process_registry_globals();
7175 include_depth--;
7176 return ret;
7177 } else {
7178 DEBUG(1, ("\"include = registry\" only effective "
7179 "in %s section\n", GLOBAL_NAME));
7180 return false;
7184 fname = alloc_sub_basic(get_current_username(),
7185 current_user_info.domain,
7186 pszParmValue);
7188 add_to_file_list(pszParmValue, fname);
7190 string_set(ptr, fname);
7192 if (file_exist(fname)) {
7193 bool ret;
7194 include_depth++;
7195 ret = pm_process(fname, do_section, do_parameter, NULL);
7196 include_depth--;
7197 SAFE_FREE(fname);
7198 return ret;
7201 DEBUG(2, ("Can't find include file %s\n", fname));
7202 SAFE_FREE(fname);
7203 return true;
7206 /***************************************************************************
7207 Handle the interpretation of the copy parameter.
7208 ***************************************************************************/
7210 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7212 bool bRetval;
7213 int iTemp;
7214 struct service serviceTemp;
7216 string_set(ptr, pszParmValue);
7218 init_service(&serviceTemp);
7220 bRetval = False;
7222 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7224 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7225 if (iTemp == iServiceIndex) {
7226 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7227 } else {
7228 copy_service(ServicePtrs[iServiceIndex],
7229 &serviceTemp,
7230 ServicePtrs[iServiceIndex]->copymap);
7231 bRetval = True;
7233 } else {
7234 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7235 bRetval = False;
7238 free_service(&serviceTemp);
7239 return (bRetval);
7242 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7244 Globals.ldap_debug_level = lp_int(pszParmValue);
7245 init_ldap_debugging();
7246 return true;
7249 /***************************************************************************
7250 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7251 parameters is:
7253 [global]
7255 idmap uid = 1000-1999
7256 idmap gid = 700-899
7258 We only do simple parsing checks here. The strings are parsed into useful
7259 structures in the idmap daemon code.
7261 ***************************************************************************/
7263 /* Some lp_ routines to return idmap [ug]id information */
7265 static uid_t idmap_uid_low, idmap_uid_high;
7266 static gid_t idmap_gid_low, idmap_gid_high;
7268 bool lp_idmap_uid(uid_t *low, uid_t *high)
7270 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7271 return False;
7273 if (low)
7274 *low = idmap_uid_low;
7276 if (high)
7277 *high = idmap_uid_high;
7279 return True;
7282 bool lp_idmap_gid(gid_t *low, gid_t *high)
7284 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7285 return False;
7287 if (low)
7288 *low = idmap_gid_low;
7290 if (high)
7291 *high = idmap_gid_high;
7293 return True;
7296 /* Do some simple checks on "idmap [ug]id" parameter values */
7298 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7300 uint32 low, high;
7302 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7303 return False;
7305 /* Parse OK */
7307 string_set(ptr, pszParmValue);
7309 idmap_uid_low = low;
7310 idmap_uid_high = high;
7312 return True;
7315 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7317 uint32 low, high;
7319 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7320 return False;
7322 /* Parse OK */
7324 string_set(ptr, pszParmValue);
7326 idmap_gid_low = low;
7327 idmap_gid_high = high;
7329 return True;
7332 /***************************************************************************
7333 Handle the DEBUG level list.
7334 ***************************************************************************/
7336 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7338 string_set(ptr, pszParmValueIn);
7339 return debug_parse_levels(pszParmValueIn);
7342 /***************************************************************************
7343 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7344 ***************************************************************************/
7346 static const char *append_ldap_suffix( const char *str )
7348 const char *suffix_string;
7351 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7352 Globals.szLdapSuffix );
7353 if ( !suffix_string ) {
7354 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7355 return "";
7358 return suffix_string;
7361 const char *lp_ldap_machine_suffix(void)
7363 if (Globals.szLdapMachineSuffix[0])
7364 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7366 return lp_string(Globals.szLdapSuffix);
7369 const char *lp_ldap_user_suffix(void)
7371 if (Globals.szLdapUserSuffix[0])
7372 return append_ldap_suffix(Globals.szLdapUserSuffix);
7374 return lp_string(Globals.szLdapSuffix);
7377 const char *lp_ldap_group_suffix(void)
7379 if (Globals.szLdapGroupSuffix[0])
7380 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7382 return lp_string(Globals.szLdapSuffix);
7385 const char *lp_ldap_idmap_suffix(void)
7387 if (Globals.szLdapIdmapSuffix[0])
7388 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7390 return lp_string(Globals.szLdapSuffix);
7393 /****************************************************************************
7394 set the value for a P_ENUM
7395 ***************************************************************************/
7397 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7398 int *ptr )
7400 int i;
7402 for (i = 0; parm->enum_list[i].name; i++) {
7403 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7404 *ptr = parm->enum_list[i].value;
7405 return;
7408 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7409 pszParmValue, parm->label));
7412 /***************************************************************************
7413 ***************************************************************************/
7415 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7417 static int parm_num = -1;
7418 struct service *s;
7420 if ( parm_num == -1 )
7421 parm_num = map_parameter( "printing" );
7423 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7425 if ( snum < 0 )
7426 s = &sDefault;
7427 else
7428 s = ServicePtrs[snum];
7430 init_printer_values( s );
7432 return True;
7436 /***************************************************************************
7437 Initialise a copymap.
7438 ***************************************************************************/
7440 static void init_copymap(struct service *pservice)
7442 int i;
7443 if (pservice->copymap) {
7444 bitmap_free(pservice->copymap);
7446 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7447 if (!pservice->copymap)
7448 DEBUG(0,
7449 ("Couldn't allocate copymap!! (size %d)\n",
7450 (int)NUMPARAMETERS));
7451 else
7452 for (i = 0; i < NUMPARAMETERS; i++)
7453 bitmap_set(pservice->copymap, i);
7456 /***************************************************************************
7457 Return the local pointer to a parameter given a service struct and the
7458 pointer into the default structure.
7459 ***************************************************************************/
7461 static void *lp_local_ptr(struct service *service, void *ptr)
7463 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7466 /***************************************************************************
7467 Return the local pointer to a parameter given the service number and the
7468 pointer into the default structure.
7469 ***************************************************************************/
7471 void *lp_local_ptr_by_snum(int snum, void *ptr)
7473 return lp_local_ptr(ServicePtrs[snum], ptr);
7476 /***************************************************************************
7477 Process a parameter for a particular service number. If snum < 0
7478 then assume we are in the globals.
7479 ***************************************************************************/
7481 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7483 int parmnum, i;
7484 void *parm_ptr = NULL; /* where we are going to store the result */
7485 void *def_ptr = NULL;
7486 struct param_opt_struct **opt_list;
7488 parmnum = map_parameter(pszParmName);
7490 if (parmnum < 0) {
7491 if (strchr(pszParmName, ':') == NULL) {
7492 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7493 pszParmName));
7494 return (True);
7498 * We've got a parametric option
7501 opt_list = (snum < 0)
7502 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7503 set_param_opt(opt_list, pszParmName, pszParmValue);
7505 return (True);
7508 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7509 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7510 pszParmName));
7513 def_ptr = parm_table[parmnum].ptr;
7515 /* we might point at a service, the default service or a global */
7516 if (snum < 0) {
7517 parm_ptr = def_ptr;
7518 } else {
7519 if (parm_table[parmnum].p_class == P_GLOBAL) {
7520 DEBUG(0,
7521 ("Global parameter %s found in service section!\n",
7522 pszParmName));
7523 return (True);
7525 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7528 if (snum >= 0) {
7529 if (!ServicePtrs[snum]->copymap)
7530 init_copymap(ServicePtrs[snum]);
7532 /* this handles the aliases - set the copymap for other entries with
7533 the same data pointer */
7534 for (i = 0; parm_table[i].label; i++)
7535 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7536 bitmap_clear(ServicePtrs[snum]->copymap, i);
7539 /* if it is a special case then go ahead */
7540 if (parm_table[parmnum].special) {
7541 return parm_table[parmnum].special(snum, pszParmValue,
7542 (char **)parm_ptr);
7545 /* now switch on the type of variable it is */
7546 switch (parm_table[parmnum].type)
7548 case P_BOOL:
7549 *(bool *)parm_ptr = lp_bool(pszParmValue);
7550 break;
7552 case P_BOOLREV:
7553 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7554 break;
7556 case P_INTEGER:
7557 *(int *)parm_ptr = lp_int(pszParmValue);
7558 break;
7560 case P_CHAR:
7561 *(char *)parm_ptr = *pszParmValue;
7562 break;
7564 case P_OCTAL:
7565 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7566 if ( i != 1 ) {
7567 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7569 break;
7571 case P_LIST:
7572 TALLOC_FREE(*((char ***)parm_ptr));
7573 *(char ***)parm_ptr = str_list_make_v3(
7574 talloc_autofree_context(), pszParmValue, NULL);
7575 break;
7577 case P_STRING:
7578 string_set((char **)parm_ptr, pszParmValue);
7579 break;
7581 case P_USTRING:
7582 string_set((char **)parm_ptr, pszParmValue);
7583 strupper_m(*(char **)parm_ptr);
7584 break;
7586 case P_ENUM:
7587 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7588 break;
7589 case P_SEP:
7590 break;
7593 return (True);
7596 /***************************************************************************
7597 Process a parameter.
7598 ***************************************************************************/
7600 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7601 void *userdata)
7603 if (!bInGlobalSection && bGlobalOnly)
7604 return (True);
7606 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7608 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7609 pszParmName, pszParmValue));
7612 /***************************************************************************
7613 Print a parameter of the specified type.
7614 ***************************************************************************/
7616 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7618 int i;
7619 switch (p->type)
7621 case P_ENUM:
7622 for (i = 0; p->enum_list[i].name; i++) {
7623 if (*(int *)ptr == p->enum_list[i].value) {
7624 fprintf(f, "%s",
7625 p->enum_list[i].name);
7626 break;
7629 break;
7631 case P_BOOL:
7632 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7633 break;
7635 case P_BOOLREV:
7636 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7637 break;
7639 case P_INTEGER:
7640 fprintf(f, "%d", *(int *)ptr);
7641 break;
7643 case P_CHAR:
7644 fprintf(f, "%c", *(char *)ptr);
7645 break;
7647 case P_OCTAL: {
7648 char *o = octal_string(*(int *)ptr);
7649 fprintf(f, "%s", o);
7650 TALLOC_FREE(o);
7651 break;
7654 case P_LIST:
7655 if ((char ***)ptr && *(char ***)ptr) {
7656 char **list = *(char ***)ptr;
7657 for (; *list; list++) {
7658 /* surround strings with whitespace in double quotes */
7659 if ( strchr_m( *list, ' ' ) )
7660 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7661 else
7662 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7665 break;
7667 case P_STRING:
7668 case P_USTRING:
7669 if (*(char **)ptr) {
7670 fprintf(f, "%s", *(char **)ptr);
7672 break;
7673 case P_SEP:
7674 break;
7678 /***************************************************************************
7679 Check if two parameters are equal.
7680 ***************************************************************************/
7682 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7684 switch (type) {
7685 case P_BOOL:
7686 case P_BOOLREV:
7687 return (*((bool *)ptr1) == *((bool *)ptr2));
7689 case P_INTEGER:
7690 case P_ENUM:
7691 case P_OCTAL:
7692 return (*((int *)ptr1) == *((int *)ptr2));
7694 case P_CHAR:
7695 return (*((char *)ptr1) == *((char *)ptr2));
7697 case P_LIST:
7698 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7700 case P_STRING:
7701 case P_USTRING:
7703 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7704 if (p1 && !*p1)
7705 p1 = NULL;
7706 if (p2 && !*p2)
7707 p2 = NULL;
7708 return (p1 == p2 || strequal(p1, p2));
7710 case P_SEP:
7711 break;
7713 return (False);
7716 /***************************************************************************
7717 Initialize any local varients in the sDefault table.
7718 ***************************************************************************/
7720 void init_locals(void)
7722 /* None as yet. */
7725 /***************************************************************************
7726 Process a new section (service). At this stage all sections are services.
7727 Later we'll have special sections that permit server parameters to be set.
7728 Returns True on success, False on failure.
7729 ***************************************************************************/
7731 static bool do_section(const char *pszSectionName, void *userdata)
7733 bool bRetval;
7734 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7735 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7736 bRetval = False;
7738 /* if we were in a global section then do the local inits */
7739 if (bInGlobalSection && !isglobal)
7740 init_locals();
7742 /* if we've just struck a global section, note the fact. */
7743 bInGlobalSection = isglobal;
7745 /* check for multiple global sections */
7746 if (bInGlobalSection) {
7747 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7748 return (True);
7751 if (!bInGlobalSection && bGlobalOnly)
7752 return (True);
7754 /* if we have a current service, tidy it up before moving on */
7755 bRetval = True;
7757 if (iServiceIndex >= 0)
7758 bRetval = service_ok(iServiceIndex);
7760 /* if all is still well, move to the next record in the services array */
7761 if (bRetval) {
7762 /* We put this here to avoid an odd message order if messages are */
7763 /* issued by the post-processing of a previous section. */
7764 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7766 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7767 < 0) {
7768 DEBUG(0, ("Failed to add a new service\n"));
7769 return (False);
7773 return (bRetval);
7777 /***************************************************************************
7778 Determine if a partcular base parameter is currentl set to the default value.
7779 ***************************************************************************/
7781 static bool is_default(int i)
7783 if (!defaults_saved)
7784 return False;
7785 switch (parm_table[i].type) {
7786 case P_LIST:
7787 return str_list_equal((const char **)parm_table[i].def.lvalue,
7788 *(const char ***)parm_table[i].ptr);
7789 case P_STRING:
7790 case P_USTRING:
7791 return strequal(parm_table[i].def.svalue,
7792 *(char **)parm_table[i].ptr);
7793 case P_BOOL:
7794 case P_BOOLREV:
7795 return parm_table[i].def.bvalue ==
7796 *(bool *)parm_table[i].ptr;
7797 case P_CHAR:
7798 return parm_table[i].def.cvalue ==
7799 *(char *)parm_table[i].ptr;
7800 case P_INTEGER:
7801 case P_OCTAL:
7802 case P_ENUM:
7803 return parm_table[i].def.ivalue ==
7804 *(int *)parm_table[i].ptr;
7805 case P_SEP:
7806 break;
7808 return False;
7811 /***************************************************************************
7812 Display the contents of the global structure.
7813 ***************************************************************************/
7815 static void dump_globals(FILE *f)
7817 int i;
7818 struct param_opt_struct *data;
7820 fprintf(f, "[global]\n");
7822 for (i = 0; parm_table[i].label; i++)
7823 if (parm_table[i].p_class == P_GLOBAL &&
7824 !(parm_table[i].flags & FLAG_META) &&
7825 parm_table[i].ptr &&
7826 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7827 if (defaults_saved && is_default(i))
7828 continue;
7829 fprintf(f, "\t%s = ", parm_table[i].label);
7830 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7831 fprintf(f, "\n");
7833 if (Globals.param_opt != NULL) {
7834 data = Globals.param_opt;
7835 while(data) {
7836 fprintf(f, "\t%s = %s\n", data->key, data->value);
7837 data = data->next;
7843 /***************************************************************************
7844 Return True if a local parameter is currently set to the global default.
7845 ***************************************************************************/
7847 bool lp_is_default(int snum, struct parm_struct *parm)
7849 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7851 return equal_parameter(parm->type,
7852 ((char *)ServicePtrs[snum]) + pdiff,
7853 ((char *)&sDefault) + pdiff);
7856 /***************************************************************************
7857 Display the contents of a single services record.
7858 ***************************************************************************/
7860 static void dump_a_service(struct service *pService, FILE * f)
7862 int i;
7863 struct param_opt_struct *data;
7865 if (pService != &sDefault)
7866 fprintf(f, "[%s]\n", pService->szService);
7868 for (i = 0; parm_table[i].label; i++) {
7870 if (parm_table[i].p_class == P_LOCAL &&
7871 !(parm_table[i].flags & FLAG_META) &&
7872 parm_table[i].ptr &&
7873 (*parm_table[i].label != '-') &&
7874 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7877 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7879 if (pService == &sDefault) {
7880 if (defaults_saved && is_default(i))
7881 continue;
7882 } else {
7883 if (equal_parameter(parm_table[i].type,
7884 ((char *)pService) +
7885 pdiff,
7886 ((char *)&sDefault) +
7887 pdiff))
7888 continue;
7891 fprintf(f, "\t%s = ", parm_table[i].label);
7892 print_parameter(&parm_table[i],
7893 ((char *)pService) + pdiff, f);
7894 fprintf(f, "\n");
7898 if (pService->param_opt != NULL) {
7899 data = pService->param_opt;
7900 while(data) {
7901 fprintf(f, "\t%s = %s\n", data->key, data->value);
7902 data = data->next;
7907 /***************************************************************************
7908 Display the contents of a parameter of a single services record.
7909 ***************************************************************************/
7911 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7913 int i;
7914 bool result = False;
7915 parm_class p_class;
7916 unsigned flag = 0;
7917 fstring local_parm_name;
7918 char *parm_opt;
7919 const char *parm_opt_value;
7921 /* check for parametrical option */
7922 fstrcpy( local_parm_name, parm_name);
7923 parm_opt = strchr( local_parm_name, ':');
7925 if (parm_opt) {
7926 *parm_opt = '\0';
7927 parm_opt++;
7928 if (strlen(parm_opt)) {
7929 parm_opt_value = lp_parm_const_string( snum,
7930 local_parm_name, parm_opt, NULL);
7931 if (parm_opt_value) {
7932 printf( "%s\n", parm_opt_value);
7933 result = True;
7936 return result;
7939 /* check for a key and print the value */
7940 if (isGlobal) {
7941 p_class = P_GLOBAL;
7942 flag = FLAG_GLOBAL;
7943 } else
7944 p_class = P_LOCAL;
7946 for (i = 0; parm_table[i].label; i++) {
7947 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7948 !(parm_table[i].flags & FLAG_META) &&
7949 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7950 parm_table[i].ptr &&
7951 (*parm_table[i].label != '-') &&
7952 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7954 void *ptr;
7956 if (isGlobal) {
7957 ptr = parm_table[i].ptr;
7958 } else {
7959 struct service *pService = ServicePtrs[snum];
7960 ptr = ((char *)pService) +
7961 PTR_DIFF(parm_table[i].ptr, &sDefault);
7964 print_parameter(&parm_table[i],
7965 ptr, f);
7966 fprintf(f, "\n");
7967 result = True;
7968 break;
7972 return result;
7975 /***************************************************************************
7976 Return info about the requested parameter (given as a string).
7977 Return NULL when the string is not a valid parameter name.
7978 ***************************************************************************/
7980 struct parm_struct *lp_get_parameter(const char *param_name)
7982 int num = map_parameter(param_name);
7984 if (num < 0) {
7985 return NULL;
7988 return &parm_table[num];
7991 /***************************************************************************
7992 Return info about the next parameter in a service.
7993 snum==GLOBAL_SECTION_SNUM gives the globals.
7994 Return NULL when out of parameters.
7995 ***************************************************************************/
7997 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7999 if (snum < 0) {
8000 /* do the globals */
8001 for (; parm_table[*i].label; (*i)++) {
8002 if (parm_table[*i].p_class == P_SEPARATOR)
8003 return &parm_table[(*i)++];
8005 if (!parm_table[*i].ptr
8006 || (*parm_table[*i].label == '-'))
8007 continue;
8009 if ((*i) > 0
8010 && (parm_table[*i].ptr ==
8011 parm_table[(*i) - 1].ptr))
8012 continue;
8014 if (is_default(*i) && !allparameters)
8015 continue;
8017 return &parm_table[(*i)++];
8019 } else {
8020 struct service *pService = ServicePtrs[snum];
8022 for (; parm_table[*i].label; (*i)++) {
8023 if (parm_table[*i].p_class == P_SEPARATOR)
8024 return &parm_table[(*i)++];
8026 if (parm_table[*i].p_class == P_LOCAL &&
8027 parm_table[*i].ptr &&
8028 (*parm_table[*i].label != '-') &&
8029 ((*i) == 0 ||
8030 (parm_table[*i].ptr !=
8031 parm_table[(*i) - 1].ptr)))
8033 int pdiff =
8034 PTR_DIFF(parm_table[*i].ptr,
8035 &sDefault);
8037 if (allparameters ||
8038 !equal_parameter(parm_table[*i].type,
8039 ((char *)pService) +
8040 pdiff,
8041 ((char *)&sDefault) +
8042 pdiff))
8044 return &parm_table[(*i)++];
8050 return NULL;
8054 #if 0
8055 /***************************************************************************
8056 Display the contents of a single copy structure.
8057 ***************************************************************************/
8058 static void dump_copy_map(bool *pcopymap)
8060 int i;
8061 if (!pcopymap)
8062 return;
8064 printf("\n\tNon-Copied parameters:\n");
8066 for (i = 0; parm_table[i].label; i++)
8067 if (parm_table[i].p_class == P_LOCAL &&
8068 parm_table[i].ptr && !pcopymap[i] &&
8069 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8071 printf("\t\t%s\n", parm_table[i].label);
8074 #endif
8076 /***************************************************************************
8077 Return TRUE if the passed service number is within range.
8078 ***************************************************************************/
8080 bool lp_snum_ok(int iService)
8082 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8085 /***************************************************************************
8086 Auto-load some home services.
8087 ***************************************************************************/
8089 static void lp_add_auto_services(char *str)
8091 char *s;
8092 char *p;
8093 int homes;
8094 char *saveptr;
8096 if (!str)
8097 return;
8099 s = SMB_STRDUP(str);
8100 if (!s)
8101 return;
8103 homes = lp_servicenumber(HOMES_NAME);
8105 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8106 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8107 char *home;
8109 if (lp_servicenumber(p) >= 0)
8110 continue;
8112 home = get_user_home_dir(talloc_tos(), p);
8114 if (home && homes >= 0)
8115 lp_add_home(p, homes, p, home);
8117 TALLOC_FREE(home);
8119 SAFE_FREE(s);
8122 /***************************************************************************
8123 Auto-load one printer.
8124 ***************************************************************************/
8126 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8128 int printers = lp_servicenumber(PRINTERS_NAME);
8129 int i;
8131 if (lp_servicenumber(name) < 0) {
8132 lp_add_printer(name, printers);
8133 if ((i = lp_servicenumber(name)) >= 0) {
8134 string_set(&ServicePtrs[i]->comment, comment);
8135 ServicePtrs[i]->autoloaded = True;
8140 /***************************************************************************
8141 Have we loaded a services file yet?
8142 ***************************************************************************/
8144 bool lp_loaded(void)
8146 return (bLoaded);
8149 /***************************************************************************
8150 Unload unused services.
8151 ***************************************************************************/
8153 void lp_killunused(bool (*snumused) (int))
8155 int i;
8156 for (i = 0; i < iNumServices; i++) {
8157 if (!VALID(i))
8158 continue;
8160 /* don't kill autoloaded or usershare services */
8161 if ( ServicePtrs[i]->autoloaded ||
8162 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8163 continue;
8166 if (!snumused || !snumused(i)) {
8167 free_service_byindex(i);
8173 * Kill all except autoloaded and usershare services - convenience wrapper
8175 void lp_kill_all_services(void)
8177 lp_killunused(NULL);
8180 /***************************************************************************
8181 Unload a service.
8182 ***************************************************************************/
8184 void lp_killservice(int iServiceIn)
8186 if (VALID(iServiceIn)) {
8187 free_service_byindex(iServiceIn);
8191 /***************************************************************************
8192 Save the curent values of all global and sDefault parameters into the
8193 defaults union. This allows swat and testparm to show only the
8194 changed (ie. non-default) parameters.
8195 ***************************************************************************/
8197 static void lp_save_defaults(void)
8199 int i;
8200 for (i = 0; parm_table[i].label; i++) {
8201 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8202 continue;
8203 switch (parm_table[i].type) {
8204 case P_LIST:
8205 parm_table[i].def.lvalue = str_list_copy(
8206 NULL, *(const char ***)parm_table[i].ptr);
8207 break;
8208 case P_STRING:
8209 case P_USTRING:
8210 if (parm_table[i].ptr) {
8211 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8212 } else {
8213 parm_table[i].def.svalue = NULL;
8215 break;
8216 case P_BOOL:
8217 case P_BOOLREV:
8218 parm_table[i].def.bvalue =
8219 *(bool *)parm_table[i].ptr;
8220 break;
8221 case P_CHAR:
8222 parm_table[i].def.cvalue =
8223 *(char *)parm_table[i].ptr;
8224 break;
8225 case P_INTEGER:
8226 case P_OCTAL:
8227 case P_ENUM:
8228 parm_table[i].def.ivalue =
8229 *(int *)parm_table[i].ptr;
8230 break;
8231 case P_SEP:
8232 break;
8235 defaults_saved = True;
8238 /*******************************************************************
8239 Set the server type we will announce as via nmbd.
8240 ********************************************************************/
8242 static const struct srv_role_tab {
8243 uint32 role;
8244 const char *role_str;
8245 } srv_role_tab [] = {
8246 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8247 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8248 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8249 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8250 { 0, NULL }
8253 const char* server_role_str(uint32 role)
8255 int i = 0;
8256 for (i=0; srv_role_tab[i].role_str; i++) {
8257 if (role == srv_role_tab[i].role) {
8258 return srv_role_tab[i].role_str;
8261 return NULL;
8264 static void set_server_role(void)
8266 server_role = ROLE_STANDALONE;
8268 switch (lp_security()) {
8269 case SEC_SHARE:
8270 if (lp_domain_logons())
8271 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8272 break;
8273 case SEC_SERVER:
8274 if (lp_domain_logons())
8275 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8276 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8277 server_role = ROLE_STANDALONE;
8278 break;
8279 case SEC_DOMAIN:
8280 if (lp_domain_logons()) {
8281 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8282 server_role = ROLE_DOMAIN_BDC;
8283 break;
8285 server_role = ROLE_DOMAIN_MEMBER;
8286 break;
8287 case SEC_ADS:
8288 if (lp_domain_logons()) {
8289 server_role = ROLE_DOMAIN_PDC;
8290 break;
8292 server_role = ROLE_DOMAIN_MEMBER;
8293 break;
8294 case SEC_USER:
8295 if (lp_domain_logons()) {
8297 if (Globals.iDomainMaster) /* auto or yes */
8298 server_role = ROLE_DOMAIN_PDC;
8299 else
8300 server_role = ROLE_DOMAIN_BDC;
8302 break;
8303 default:
8304 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8305 break;
8308 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8311 /***********************************************************
8312 If we should send plaintext/LANMAN passwords in the clinet
8313 ************************************************************/
8315 static void set_allowed_client_auth(void)
8317 if (Globals.bClientNTLMv2Auth) {
8318 Globals.bClientLanManAuth = False;
8320 if (!Globals.bClientLanManAuth) {
8321 Globals.bClientPlaintextAuth = False;
8325 /***************************************************************************
8326 JRA.
8327 The following code allows smbd to read a user defined share file.
8328 Yes, this is my intent. Yes, I'm comfortable with that...
8330 THE FOLLOWING IS SECURITY CRITICAL CODE.
8332 It washes your clothes, it cleans your house, it guards you while you sleep...
8333 Do not f%^k with it....
8334 ***************************************************************************/
8336 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8338 /***************************************************************************
8339 Check allowed stat state of a usershare file.
8340 Ensure we print out who is dicking with us so the admin can
8341 get their sorry ass fired.
8342 ***************************************************************************/
8344 static bool check_usershare_stat(const char *fname,
8345 const SMB_STRUCT_STAT *psbuf)
8347 if (!S_ISREG(psbuf->st_ex_mode)) {
8348 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8349 "not a regular file\n",
8350 fname, (unsigned int)psbuf->st_ex_uid ));
8351 return False;
8354 /* Ensure this doesn't have the other write bit set. */
8355 if (psbuf->st_ex_mode & S_IWOTH) {
8356 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8357 "public write. Refusing to allow as a usershare file.\n",
8358 fname, (unsigned int)psbuf->st_ex_uid ));
8359 return False;
8362 /* Should be 10k or less. */
8363 if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
8364 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8365 "too large (%u) to be a user share file.\n",
8366 fname, (unsigned int)psbuf->st_ex_uid,
8367 (unsigned int)psbuf->st_ex_size ));
8368 return False;
8371 return True;
8374 /***************************************************************************
8375 Parse the contents of a usershare file.
8376 ***************************************************************************/
8378 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8379 SMB_STRUCT_STAT *psbuf,
8380 const char *servicename,
8381 int snum,
8382 char **lines,
8383 int numlines,
8384 char **pp_sharepath,
8385 char **pp_comment,
8386 SEC_DESC **ppsd,
8387 bool *pallow_guest)
8389 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8390 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8391 int us_vers;
8392 SMB_STRUCT_DIR *dp;
8393 SMB_STRUCT_STAT sbuf;
8394 char *sharepath = NULL;
8395 char *comment = NULL;
8397 *pp_sharepath = NULL;
8398 *pp_comment = NULL;
8400 *pallow_guest = False;
8402 if (numlines < 4) {
8403 return USERSHARE_MALFORMED_FILE;
8406 if (strcmp(lines[0], "#VERSION 1") == 0) {
8407 us_vers = 1;
8408 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8409 us_vers = 2;
8410 if (numlines < 5) {
8411 return USERSHARE_MALFORMED_FILE;
8413 } else {
8414 return USERSHARE_BAD_VERSION;
8417 if (strncmp(lines[1], "path=", 5) != 0) {
8418 return USERSHARE_MALFORMED_PATH;
8421 sharepath = talloc_strdup(ctx, &lines[1][5]);
8422 if (!sharepath) {
8423 return USERSHARE_POSIX_ERR;
8425 trim_string(sharepath, " ", " ");
8427 if (strncmp(lines[2], "comment=", 8) != 0) {
8428 return USERSHARE_MALFORMED_COMMENT_DEF;
8431 comment = talloc_strdup(ctx, &lines[2][8]);
8432 if (!comment) {
8433 return USERSHARE_POSIX_ERR;
8435 trim_string(comment, " ", " ");
8436 trim_char(comment, '"', '"');
8438 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8439 return USERSHARE_MALFORMED_ACL_DEF;
8442 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8443 return USERSHARE_ACL_ERR;
8446 if (us_vers == 2) {
8447 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8448 return USERSHARE_MALFORMED_ACL_DEF;
8450 if (lines[4][9] == 'y') {
8451 *pallow_guest = True;
8455 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8456 /* Path didn't change, no checks needed. */
8457 *pp_sharepath = sharepath;
8458 *pp_comment = comment;
8459 return USERSHARE_OK;
8462 /* The path *must* be absolute. */
8463 if (sharepath[0] != '/') {
8464 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8465 servicename, sharepath));
8466 return USERSHARE_PATH_NOT_ABSOLUTE;
8469 /* If there is a usershare prefix deny list ensure one of these paths
8470 doesn't match the start of the user given path. */
8471 if (prefixdenylist) {
8472 int i;
8473 for ( i=0; prefixdenylist[i]; i++ ) {
8474 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8475 servicename, i, prefixdenylist[i], sharepath ));
8476 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8477 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8478 "usershare prefix deny list entries.\n",
8479 servicename, sharepath));
8480 return USERSHARE_PATH_IS_DENIED;
8485 /* If there is a usershare prefix allow list ensure one of these paths
8486 does match the start of the user given path. */
8488 if (prefixallowlist) {
8489 int i;
8490 for ( i=0; prefixallowlist[i]; i++ ) {
8491 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8492 servicename, i, prefixallowlist[i], sharepath ));
8493 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8494 break;
8497 if (prefixallowlist[i] == NULL) {
8498 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8499 "usershare prefix allow list entries.\n",
8500 servicename, sharepath));
8501 return USERSHARE_PATH_NOT_ALLOWED;
8505 /* Ensure this is pointing to a directory. */
8506 dp = sys_opendir(sharepath);
8508 if (!dp) {
8509 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8510 servicename, sharepath));
8511 return USERSHARE_PATH_NOT_DIRECTORY;
8514 /* Ensure the owner of the usershare file has permission to share
8515 this directory. */
8517 if (sys_stat(sharepath, &sbuf) == -1) {
8518 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8519 servicename, sharepath, strerror(errno) ));
8520 sys_closedir(dp);
8521 return USERSHARE_POSIX_ERR;
8524 sys_closedir(dp);
8526 if (!S_ISDIR(sbuf.st_ex_mode)) {
8527 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8528 servicename, sharepath ));
8529 return USERSHARE_PATH_NOT_DIRECTORY;
8532 /* Check if sharing is restricted to owner-only. */
8533 /* psbuf is the stat of the usershare definition file,
8534 sbuf is the stat of the target directory to be shared. */
8536 if (lp_usershare_owner_only()) {
8537 /* root can share anything. */
8538 if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
8539 return USERSHARE_PATH_NOT_ALLOWED;
8543 *pp_sharepath = sharepath;
8544 *pp_comment = comment;
8545 return USERSHARE_OK;
8548 /***************************************************************************
8549 Deal with a usershare file.
8550 Returns:
8551 >= 0 - snum
8552 -1 - Bad name, invalid contents.
8553 - service name already existed and not a usershare, problem
8554 with permissions to share directory etc.
8555 ***************************************************************************/
8557 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8559 SMB_STRUCT_STAT sbuf;
8560 SMB_STRUCT_STAT lsbuf;
8561 char *fname = NULL;
8562 char *sharepath = NULL;
8563 char *comment = NULL;
8564 fstring service_name;
8565 char **lines = NULL;
8566 int numlines = 0;
8567 int fd = -1;
8568 int iService = -1;
8569 TALLOC_CTX *ctx = NULL;
8570 SEC_DESC *psd = NULL;
8571 bool guest_ok = False;
8573 /* Ensure share name doesn't contain invalid characters. */
8574 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8575 DEBUG(0,("process_usershare_file: share name %s contains "
8576 "invalid characters (any of %s)\n",
8577 file_name, INVALID_SHARENAME_CHARS ));
8578 return -1;
8581 fstrcpy(service_name, file_name);
8583 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8586 /* Minimize the race condition by doing an lstat before we
8587 open and fstat. Ensure this isn't a symlink link. */
8589 if (sys_lstat(fname, &lsbuf) != 0) {
8590 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8591 fname, strerror(errno) ));
8592 SAFE_FREE(fname);
8593 return -1;
8596 /* This must be a regular file, not a symlink, directory or
8597 other strange filetype. */
8598 if (!check_usershare_stat(fname, &lsbuf)) {
8599 SAFE_FREE(fname);
8600 return -1;
8604 char *canon_name = canonicalize_servicename(service_name);
8605 TDB_DATA data = dbwrap_fetch_bystring(
8606 ServiceHash, canon_name, canon_name);
8608 iService = -1;
8610 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8611 iService = *(int *)data.dptr;
8613 TALLOC_FREE(canon_name);
8616 if (iService != -1 &&
8617 timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
8618 &lsbuf.st_ex_mtime) == 0) {
8619 /* Nothing changed - Mark valid and return. */
8620 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8621 service_name ));
8622 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8623 SAFE_FREE(fname);
8624 return iService;
8627 /* Try and open the file read only - no symlinks allowed. */
8628 #ifdef O_NOFOLLOW
8629 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8630 #else
8631 fd = sys_open(fname, O_RDONLY, 0);
8632 #endif
8634 if (fd == -1) {
8635 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8636 fname, strerror(errno) ));
8637 SAFE_FREE(fname);
8638 return -1;
8641 /* Now fstat to be *SURE* it's a regular file. */
8642 if (sys_fstat(fd, &sbuf) != 0) {
8643 close(fd);
8644 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8645 fname, strerror(errno) ));
8646 SAFE_FREE(fname);
8647 return -1;
8650 /* Is it the same dev/inode as was lstated ? */
8651 if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
8652 close(fd);
8653 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8654 "Symlink spoofing going on ?\n", fname ));
8655 SAFE_FREE(fname);
8656 return -1;
8659 /* This must be a regular file, not a symlink, directory or
8660 other strange filetype. */
8661 if (!check_usershare_stat(fname, &sbuf)) {
8662 SAFE_FREE(fname);
8663 return -1;
8666 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8668 close(fd);
8669 if (lines == NULL) {
8670 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8671 fname, (unsigned int)sbuf.st_ex_uid ));
8672 SAFE_FREE(fname);
8673 return -1;
8676 SAFE_FREE(fname);
8678 /* Should we allow printers to be shared... ? */
8679 ctx = talloc_init("usershare_sd_xctx");
8680 if (!ctx) {
8681 TALLOC_FREE(lines);
8682 return 1;
8685 if (parse_usershare_file(ctx, &sbuf, service_name,
8686 iService, lines, numlines, &sharepath,
8687 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8688 talloc_destroy(ctx);
8689 TALLOC_FREE(lines);
8690 return -1;
8693 TALLOC_FREE(lines);
8695 /* Everything ok - add the service possibly using a template. */
8696 if (iService < 0) {
8697 const struct service *sp = &sDefault;
8698 if (snum_template != -1) {
8699 sp = ServicePtrs[snum_template];
8702 if ((iService = add_a_service(sp, service_name)) < 0) {
8703 DEBUG(0, ("process_usershare_file: Failed to add "
8704 "new service %s\n", service_name));
8705 talloc_destroy(ctx);
8706 return -1;
8709 /* Read only is controlled by usershare ACL below. */
8710 ServicePtrs[iService]->bRead_only = False;
8713 /* Write the ACL of the new/modified share. */
8714 if (!set_share_security(service_name, psd)) {
8715 DEBUG(0, ("process_usershare_file: Failed to set share "
8716 "security for user share %s\n",
8717 service_name ));
8718 lp_remove_service(iService);
8719 talloc_destroy(ctx);
8720 return -1;
8723 /* If from a template it may be marked invalid. */
8724 ServicePtrs[iService]->valid = True;
8726 /* Set the service as a valid usershare. */
8727 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8729 /* Set guest access. */
8730 if (lp_usershare_allow_guests()) {
8731 ServicePtrs[iService]->bGuest_ok = guest_ok;
8734 /* And note when it was loaded. */
8735 ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
8736 string_set(&ServicePtrs[iService]->szPath, sharepath);
8737 string_set(&ServicePtrs[iService]->comment, comment);
8739 talloc_destroy(ctx);
8741 return iService;
8744 /***************************************************************************
8745 Checks if a usershare entry has been modified since last load.
8746 ***************************************************************************/
8748 static bool usershare_exists(int iService, struct timespec *last_mod)
8750 SMB_STRUCT_STAT lsbuf;
8751 const char *usersharepath = Globals.szUsersharePath;
8752 char *fname;
8754 if (asprintf(&fname, "%s/%s",
8755 usersharepath,
8756 ServicePtrs[iService]->szService) < 0) {
8757 return false;
8760 if (sys_lstat(fname, &lsbuf) != 0) {
8761 SAFE_FREE(fname);
8762 return false;
8765 if (!S_ISREG(lsbuf.st_ex_mode)) {
8766 SAFE_FREE(fname);
8767 return false;
8770 SAFE_FREE(fname);
8771 *last_mod = lsbuf.st_ex_mtime;
8772 return true;
8775 /***************************************************************************
8776 Load a usershare service by name. Returns a valid servicenumber or -1.
8777 ***************************************************************************/
8779 int load_usershare_service(const char *servicename)
8781 SMB_STRUCT_STAT sbuf;
8782 const char *usersharepath = Globals.szUsersharePath;
8783 int max_user_shares = Globals.iUsershareMaxShares;
8784 int snum_template = -1;
8786 if (*usersharepath == 0 || max_user_shares == 0) {
8787 return -1;
8790 if (sys_stat(usersharepath, &sbuf) != 0) {
8791 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8792 usersharepath, strerror(errno) ));
8793 return -1;
8796 if (!S_ISDIR(sbuf.st_ex_mode)) {
8797 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8798 usersharepath ));
8799 return -1;
8803 * This directory must be owned by root, and have the 't' bit set.
8804 * It also must not be writable by "other".
8807 #ifdef S_ISVTX
8808 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8809 #else
8810 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8811 #endif
8812 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8813 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8814 usersharepath ));
8815 return -1;
8818 /* Ensure the template share exists if it's set. */
8819 if (Globals.szUsershareTemplateShare[0]) {
8820 /* We can't use lp_servicenumber here as we are recommending that
8821 template shares have -valid=False set. */
8822 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8823 if (ServicePtrs[snum_template]->szService &&
8824 strequal(ServicePtrs[snum_template]->szService,
8825 Globals.szUsershareTemplateShare)) {
8826 break;
8830 if (snum_template == -1) {
8831 DEBUG(0,("load_usershare_service: usershare template share %s "
8832 "does not exist.\n",
8833 Globals.szUsershareTemplateShare ));
8834 return -1;
8838 return process_usershare_file(usersharepath, servicename, snum_template);
8841 /***************************************************************************
8842 Load all user defined shares from the user share directory.
8843 We only do this if we're enumerating the share list.
8844 This is the function that can delete usershares that have
8845 been removed.
8846 ***************************************************************************/
8848 int load_usershare_shares(void)
8850 SMB_STRUCT_DIR *dp;
8851 SMB_STRUCT_STAT sbuf;
8852 SMB_STRUCT_DIRENT *de;
8853 int num_usershares = 0;
8854 int max_user_shares = Globals.iUsershareMaxShares;
8855 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8856 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8857 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8858 int iService;
8859 int snum_template = -1;
8860 const char *usersharepath = Globals.szUsersharePath;
8861 int ret = lp_numservices();
8863 if (max_user_shares == 0 || *usersharepath == '\0') {
8864 return lp_numservices();
8867 if (sys_stat(usersharepath, &sbuf) != 0) {
8868 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8869 usersharepath, strerror(errno) ));
8870 return ret;
8874 * This directory must be owned by root, and have the 't' bit set.
8875 * It also must not be writable by "other".
8878 #ifdef S_ISVTX
8879 if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
8880 #else
8881 if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
8882 #endif
8883 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8884 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8885 usersharepath ));
8886 return ret;
8889 /* Ensure the template share exists if it's set. */
8890 if (Globals.szUsershareTemplateShare[0]) {
8891 /* We can't use lp_servicenumber here as we are recommending that
8892 template shares have -valid=False set. */
8893 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8894 if (ServicePtrs[snum_template]->szService &&
8895 strequal(ServicePtrs[snum_template]->szService,
8896 Globals.szUsershareTemplateShare)) {
8897 break;
8901 if (snum_template == -1) {
8902 DEBUG(0,("load_usershare_shares: usershare template share %s "
8903 "does not exist.\n",
8904 Globals.szUsershareTemplateShare ));
8905 return ret;
8909 /* Mark all existing usershares as pending delete. */
8910 for (iService = iNumServices - 1; iService >= 0; iService--) {
8911 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8912 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8916 dp = sys_opendir(usersharepath);
8917 if (!dp) {
8918 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8919 usersharepath, strerror(errno) ));
8920 return ret;
8923 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8924 (de = sys_readdir(dp));
8925 num_dir_entries++ ) {
8926 int r;
8927 const char *n = de->d_name;
8929 /* Ignore . and .. */
8930 if (*n == '.') {
8931 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8932 continue;
8936 if (n[0] == ':') {
8937 /* Temporary file used when creating a share. */
8938 num_tmp_dir_entries++;
8941 /* Allow 20% tmp entries. */
8942 if (num_tmp_dir_entries > allowed_tmp_entries) {
8943 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8944 "in directory %s\n",
8945 num_tmp_dir_entries, usersharepath));
8946 break;
8949 r = process_usershare_file(usersharepath, n, snum_template);
8950 if (r == 0) {
8951 /* Update the services count. */
8952 num_usershares++;
8953 if (num_usershares >= max_user_shares) {
8954 DEBUG(0,("load_usershare_shares: max user shares reached "
8955 "on file %s in directory %s\n",
8956 n, usersharepath ));
8957 break;
8959 } else if (r == -1) {
8960 num_bad_dir_entries++;
8963 /* Allow 20% bad entries. */
8964 if (num_bad_dir_entries > allowed_bad_entries) {
8965 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8966 "in directory %s\n",
8967 num_bad_dir_entries, usersharepath));
8968 break;
8971 /* Allow 20% bad entries. */
8972 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8973 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8974 "in directory %s\n",
8975 num_dir_entries, usersharepath));
8976 break;
8980 sys_closedir(dp);
8982 /* Sweep through and delete any non-refreshed usershares that are
8983 not currently in use. */
8984 for (iService = iNumServices - 1; iService >= 0; iService--) {
8985 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8986 if (conn_snum_used(iService)) {
8987 continue;
8989 /* Remove from the share ACL db. */
8990 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8991 lp_servicename(iService) ));
8992 delete_share_security(lp_servicename(iService));
8993 free_service_byindex(iService);
8997 return lp_numservices();
9000 /********************************************************
9001 Destroy global resources allocated in this file
9002 ********************************************************/
9004 void gfree_loadparm(void)
9006 int i;
9008 free_file_list();
9010 /* Free resources allocated to services */
9012 for ( i = 0; i < iNumServices; i++ ) {
9013 if ( VALID(i) ) {
9014 free_service_byindex(i);
9018 SAFE_FREE( ServicePtrs );
9019 iNumServices = 0;
9021 /* Now release all resources allocated to global
9022 parameters and the default service */
9024 free_global_parameters();
9028 /***************************************************************************
9029 Allow client apps to specify that they are a client
9030 ***************************************************************************/
9031 void lp_set_in_client(bool b)
9033 in_client = b;
9037 /***************************************************************************
9038 Determine if we're running in a client app
9039 ***************************************************************************/
9040 bool lp_is_in_client(void)
9042 return in_client;
9045 /***************************************************************************
9046 Load the services array from the services file. Return True on success,
9047 False on failure.
9048 ***************************************************************************/
9050 bool lp_load_ex(const char *pszFname,
9051 bool global_only,
9052 bool save_defaults,
9053 bool add_ipc,
9054 bool initialize_globals,
9055 bool allow_include_registry,
9056 bool allow_registry_shares)
9058 char *n2 = NULL;
9059 bool bRetval;
9061 bRetval = False;
9063 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9065 bInGlobalSection = True;
9066 bGlobalOnly = global_only;
9067 bAllowIncludeRegistry = allow_include_registry;
9069 init_globals(! initialize_globals);
9070 debug_init();
9072 free_file_list();
9074 if (save_defaults) {
9075 init_locals();
9076 lp_save_defaults();
9079 free_param_opts(&Globals.param_opt);
9081 /* We get sections first, so have to start 'behind' to make up */
9082 iServiceIndex = -1;
9084 if (lp_config_backend_is_file()) {
9085 n2 = alloc_sub_basic(get_current_username(),
9086 current_user_info.domain,
9087 pszFname);
9088 if (!n2) {
9089 smb_panic("lp_load_ex: out of memory");
9092 add_to_file_list(pszFname, n2);
9094 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9095 SAFE_FREE(n2);
9097 /* finish up the last section */
9098 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9099 if (bRetval) {
9100 if (iServiceIndex >= 0) {
9101 bRetval = service_ok(iServiceIndex);
9105 if (lp_config_backend_is_registry()) {
9106 /* config backend changed to registry in config file */
9108 * We need to use this extra global variable here to
9109 * survive restart: init_globals uses this as a default
9110 * for ConfigBackend. Otherwise, init_globals would
9111 * send us into an endless loop here.
9113 config_backend = CONFIG_BACKEND_REGISTRY;
9114 /* start over */
9115 DEBUG(1, ("lp_load_ex: changing to config backend "
9116 "registry\n"));
9117 init_globals(false);
9118 lp_kill_all_services();
9119 return lp_load_ex(pszFname, global_only, save_defaults,
9120 add_ipc, initialize_globals,
9121 allow_include_registry,
9122 allow_registry_shares);
9124 } else if (lp_config_backend_is_registry()) {
9125 bRetval = process_registry_globals();
9126 } else {
9127 DEBUG(0, ("Illegal config backend given: %d\n",
9128 lp_config_backend()));
9129 bRetval = false;
9132 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9133 bRetval = process_registry_shares();
9136 lp_add_auto_services(lp_auto_services());
9138 if (add_ipc) {
9139 /* When 'restrict anonymous = 2' guest connections to ipc$
9140 are denied */
9141 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9142 if ( lp_enable_asu_support() ) {
9143 lp_add_ipc("ADMIN$", false);
9147 set_server_role();
9148 set_default_server_announce_type();
9149 set_allowed_client_auth();
9151 bLoaded = True;
9153 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9154 /* if bWINSsupport is true and we are in the client */
9155 if (lp_is_in_client() && Globals.bWINSsupport) {
9156 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9159 init_iconv();
9161 bAllowIncludeRegistry = true;
9163 return (bRetval);
9166 bool lp_load(const char *pszFname,
9167 bool global_only,
9168 bool save_defaults,
9169 bool add_ipc,
9170 bool initialize_globals)
9172 return lp_load_ex(pszFname,
9173 global_only,
9174 save_defaults,
9175 add_ipc,
9176 initialize_globals,
9177 true, false);
9180 bool lp_load_initial_only(const char *pszFname)
9182 return lp_load_ex(pszFname,
9183 true,
9184 false,
9185 false,
9186 true,
9187 false,
9188 false);
9191 bool lp_load_with_registry_shares(const char *pszFname,
9192 bool global_only,
9193 bool save_defaults,
9194 bool add_ipc,
9195 bool initialize_globals)
9197 return lp_load_ex(pszFname,
9198 global_only,
9199 save_defaults,
9200 add_ipc,
9201 initialize_globals,
9202 true,
9203 true);
9206 /***************************************************************************
9207 Return the max number of services.
9208 ***************************************************************************/
9210 int lp_numservices(void)
9212 return (iNumServices);
9215 /***************************************************************************
9216 Display the contents of the services array in human-readable form.
9217 ***************************************************************************/
9219 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9221 int iService;
9223 if (show_defaults)
9224 defaults_saved = False;
9226 dump_globals(f);
9228 dump_a_service(&sDefault, f);
9230 for (iService = 0; iService < maxtoprint; iService++) {
9231 fprintf(f,"\n");
9232 lp_dump_one(f, show_defaults, iService);
9236 /***************************************************************************
9237 Display the contents of one service in human-readable form.
9238 ***************************************************************************/
9240 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9242 if (VALID(snum)) {
9243 if (ServicePtrs[snum]->szService[0] == '\0')
9244 return;
9245 dump_a_service(ServicePtrs[snum], f);
9249 /***************************************************************************
9250 Return the number of the service with the given name, or -1 if it doesn't
9251 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9252 getservicebyname()! This works ONLY if all services have been loaded, and
9253 does not copy the found service.
9254 ***************************************************************************/
9256 int lp_servicenumber(const char *pszServiceName)
9258 int iService;
9259 fstring serviceName;
9261 if (!pszServiceName) {
9262 return GLOBAL_SECTION_SNUM;
9265 for (iService = iNumServices - 1; iService >= 0; iService--) {
9266 if (VALID(iService) && ServicePtrs[iService]->szService) {
9268 * The substitution here is used to support %U is
9269 * service names
9271 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9272 standard_sub_basic(get_current_username(),
9273 current_user_info.domain,
9274 serviceName,sizeof(serviceName));
9275 if (strequal(serviceName, pszServiceName)) {
9276 break;
9281 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9282 struct timespec last_mod;
9284 if (!usershare_exists(iService, &last_mod)) {
9285 /* Remove the share security tdb entry for it. */
9286 delete_share_security(lp_servicename(iService));
9287 /* Remove it from the array. */
9288 free_service_byindex(iService);
9289 /* Doesn't exist anymore. */
9290 return GLOBAL_SECTION_SNUM;
9293 /* Has it been modified ? If so delete and reload. */
9294 if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
9295 &last_mod) < 0) {
9296 /* Remove it from the array. */
9297 free_service_byindex(iService);
9298 /* and now reload it. */
9299 iService = load_usershare_service(pszServiceName);
9303 if (iService < 0) {
9304 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9305 return GLOBAL_SECTION_SNUM;
9308 return (iService);
9311 bool share_defined(const char *service_name)
9313 return (lp_servicenumber(service_name) != -1);
9316 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9317 const char *sharename)
9319 struct share_params *result;
9320 char *sname;
9321 int snum;
9323 if (!(sname = SMB_STRDUP(sharename))) {
9324 return NULL;
9327 snum = find_service(sname);
9328 SAFE_FREE(sname);
9330 if (snum < 0) {
9331 return NULL;
9334 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9335 DEBUG(0, ("talloc failed\n"));
9336 return NULL;
9339 result->service = snum;
9340 return result;
9343 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9345 struct share_iterator *result;
9347 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9348 DEBUG(0, ("talloc failed\n"));
9349 return NULL;
9352 result->next_id = 0;
9353 return result;
9356 struct share_params *next_share(struct share_iterator *list)
9358 struct share_params *result;
9360 while (!lp_snum_ok(list->next_id) &&
9361 (list->next_id < lp_numservices())) {
9362 list->next_id += 1;
9365 if (list->next_id >= lp_numservices()) {
9366 return NULL;
9369 if (!(result = TALLOC_P(list, struct share_params))) {
9370 DEBUG(0, ("talloc failed\n"));
9371 return NULL;
9374 result->service = list->next_id;
9375 list->next_id += 1;
9376 return result;
9379 struct share_params *next_printer(struct share_iterator *list)
9381 struct share_params *result;
9383 while ((result = next_share(list)) != NULL) {
9384 if (lp_print_ok(result->service)) {
9385 break;
9388 return result;
9392 * This is a hack for a transition period until we transformed all code from
9393 * service numbers to struct share_params.
9396 struct share_params *snum2params_static(int snum)
9398 static struct share_params result;
9399 result.service = snum;
9400 return &result;
9403 /*******************************************************************
9404 A useful volume label function.
9405 ********************************************************************/
9407 const char *volume_label(int snum)
9409 char *ret;
9410 const char *label = lp_volume(snum);
9411 if (!*label) {
9412 label = lp_servicename(snum);
9415 /* This returns a 33 byte guarenteed null terminated string. */
9416 ret = talloc_strndup(talloc_tos(), label, 32);
9417 if (!ret) {
9418 return "";
9420 return ret;
9423 /*******************************************************************
9424 Set the server type we will announce as via nmbd.
9425 ********************************************************************/
9427 static void set_default_server_announce_type(void)
9429 default_server_announce = 0;
9430 default_server_announce |= SV_TYPE_WORKSTATION;
9431 default_server_announce |= SV_TYPE_SERVER;
9432 default_server_announce |= SV_TYPE_SERVER_UNIX;
9434 /* note that the flag should be set only if we have a
9435 printer service but nmbd doesn't actually load the
9436 services so we can't tell --jerry */
9438 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9440 switch (lp_announce_as()) {
9441 case ANNOUNCE_AS_NT_SERVER:
9442 default_server_announce |= SV_TYPE_SERVER_NT;
9443 /* fall through... */
9444 case ANNOUNCE_AS_NT_WORKSTATION:
9445 default_server_announce |= SV_TYPE_NT;
9446 break;
9447 case ANNOUNCE_AS_WIN95:
9448 default_server_announce |= SV_TYPE_WIN95_PLUS;
9449 break;
9450 case ANNOUNCE_AS_WFW:
9451 default_server_announce |= SV_TYPE_WFW;
9452 break;
9453 default:
9454 break;
9457 switch (lp_server_role()) {
9458 case ROLE_DOMAIN_MEMBER:
9459 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9460 break;
9461 case ROLE_DOMAIN_PDC:
9462 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9463 break;
9464 case ROLE_DOMAIN_BDC:
9465 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9466 break;
9467 case ROLE_STANDALONE:
9468 default:
9469 break;
9471 if (lp_time_server())
9472 default_server_announce |= SV_TYPE_TIME_SOURCE;
9474 if (lp_host_msdfs())
9475 default_server_announce |= SV_TYPE_DFS_SERVER;
9478 /***********************************************************
9479 returns role of Samba server
9480 ************************************************************/
9482 int lp_server_role(void)
9484 return server_role;
9487 /***********************************************************
9488 If we are PDC then prefer us as DMB
9489 ************************************************************/
9491 bool lp_domain_master(void)
9493 if (Globals.iDomainMaster == Auto)
9494 return (lp_server_role() == ROLE_DOMAIN_PDC);
9496 return (bool)Globals.iDomainMaster;
9499 /***********************************************************
9500 If we are DMB then prefer us as LMB
9501 ************************************************************/
9503 bool lp_preferred_master(void)
9505 if (Globals.iPreferredMaster == Auto)
9506 return (lp_local_master() && lp_domain_master());
9508 return (bool)Globals.iPreferredMaster;
9511 /*******************************************************************
9512 Remove a service.
9513 ********************************************************************/
9515 void lp_remove_service(int snum)
9517 ServicePtrs[snum]->valid = False;
9518 invalid_services[num_invalid_services++] = snum;
9521 /*******************************************************************
9522 Copy a service.
9523 ********************************************************************/
9525 void lp_copy_service(int snum, const char *new_name)
9527 do_section(new_name, NULL);
9528 if (snum >= 0) {
9529 snum = lp_servicenumber(new_name);
9530 if (snum >= 0)
9531 lp_do_parameter(snum, "copy", lp_servicename(snum));
9536 /*******************************************************************
9537 Get the default server type we will announce as via nmbd.
9538 ********************************************************************/
9540 int lp_default_server_announce(void)
9542 return default_server_announce;
9545 /*******************************************************************
9546 Split the announce version into major and minor numbers.
9547 ********************************************************************/
9549 int lp_major_announce_version(void)
9551 static bool got_major = False;
9552 static int major_version = DEFAULT_MAJOR_VERSION;
9553 char *vers;
9554 char *p;
9556 if (got_major)
9557 return major_version;
9559 got_major = True;
9560 if ((vers = lp_announce_version()) == NULL)
9561 return major_version;
9563 if ((p = strchr_m(vers, '.')) == 0)
9564 return major_version;
9566 *p = '\0';
9567 major_version = atoi(vers);
9568 return major_version;
9571 int lp_minor_announce_version(void)
9573 static bool got_minor = False;
9574 static int minor_version = DEFAULT_MINOR_VERSION;
9575 char *vers;
9576 char *p;
9578 if (got_minor)
9579 return minor_version;
9581 got_minor = True;
9582 if ((vers = lp_announce_version()) == NULL)
9583 return minor_version;
9585 if ((p = strchr_m(vers, '.')) == 0)
9586 return minor_version;
9588 p++;
9589 minor_version = atoi(p);
9590 return minor_version;
9593 /***********************************************************
9594 Set the global name resolution order (used in smbclient).
9595 ************************************************************/
9597 void lp_set_name_resolve_order(const char *new_order)
9599 string_set(&Globals.szNameResolveOrder, new_order);
9602 const char *lp_printername(int snum)
9604 const char *ret = _lp_printername(snum);
9605 if (ret == NULL || (ret != NULL && *ret == '\0'))
9606 ret = lp_const_servicename(snum);
9608 return ret;
9612 /***********************************************************
9613 Allow daemons such as winbindd to fix their logfile name.
9614 ************************************************************/
9616 void lp_set_logfile(const char *name)
9618 string_set(&Globals.szLogFile, name);
9619 debug_set_logfile(name);
9622 /*******************************************************************
9623 Return the max print jobs per queue.
9624 ********************************************************************/
9626 int lp_maxprintjobs(int snum)
9628 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9629 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9630 maxjobs = PRINT_MAX_JOBID - 1;
9632 return maxjobs;
9635 const char *lp_printcapname(void)
9637 if ((Globals.szPrintcapname != NULL) &&
9638 (Globals.szPrintcapname[0] != '\0'))
9639 return Globals.szPrintcapname;
9641 if (sDefault.iPrinting == PRINT_CUPS) {
9642 #ifdef HAVE_CUPS
9643 return "cups";
9644 #else
9645 return "lpstat";
9646 #endif
9649 if (sDefault.iPrinting == PRINT_BSD)
9650 return "/etc/printcap";
9652 return PRINTCAP_NAME;
9655 static uint32 spoolss_state;
9657 bool lp_disable_spoolss( void )
9659 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9660 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9662 return spoolss_state == SVCCTL_STOPPED ? True : False;
9665 void lp_set_spoolss_state( uint32 state )
9667 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9669 spoolss_state = state;
9672 uint32 lp_get_spoolss_state( void )
9674 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9677 /*******************************************************************
9678 Ensure we don't use sendfile if server smb signing is active.
9679 ********************************************************************/
9681 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state)
9683 bool sign_active = false;
9685 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9686 if (Protocol < PROTOCOL_NT1) {
9687 return false;
9689 if (signing_state) {
9690 sign_active = smb_signing_is_active(signing_state);
9692 return (_lp_use_sendfile(snum) &&
9693 (get_remote_arch() != RA_WIN95) &&
9694 !sign_active);
9697 /*******************************************************************
9698 Turn off sendfile if we find the underlying OS doesn't support it.
9699 ********************************************************************/
9701 void set_use_sendfile(int snum, bool val)
9703 if (LP_SNUM_OK(snum))
9704 ServicePtrs[snum]->bUseSendfile = val;
9705 else
9706 sDefault.bUseSendfile = val;
9709 /*******************************************************************
9710 Turn off storing DOS attributes if this share doesn't support it.
9711 ********************************************************************/
9713 void set_store_dos_attributes(int snum, bool val)
9715 if (!LP_SNUM_OK(snum))
9716 return;
9717 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9720 void lp_set_mangling_method(const char *new_method)
9722 string_set(&Globals.szManglingMethod, new_method);
9725 /*******************************************************************
9726 Global state for POSIX pathname processing.
9727 ********************************************************************/
9729 static bool posix_pathnames;
9731 bool lp_posix_pathnames(void)
9733 return posix_pathnames;
9736 /*******************************************************************
9737 Change everything needed to ensure POSIX pathname processing (currently
9738 not much).
9739 ********************************************************************/
9741 void lp_set_posix_pathnames(void)
9743 posix_pathnames = True;
9746 /*******************************************************************
9747 Global state for POSIX lock processing - CIFS unix extensions.
9748 ********************************************************************/
9750 bool posix_default_lock_was_set;
9751 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9753 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9755 if (posix_default_lock_was_set) {
9756 return posix_cifsx_locktype;
9757 } else {
9758 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9762 /*******************************************************************
9763 ********************************************************************/
9765 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9767 posix_default_lock_was_set = True;
9768 posix_cifsx_locktype = val;
9771 int lp_min_receive_file_size(void)
9773 if (Globals.iminreceivefile < 0) {
9774 return 0;
9776 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9779 /*******************************************************************
9780 If socket address is an empty character string, it is necessary to
9781 define it as "0.0.0.0".
9782 ********************************************************************/
9784 const char *lp_socket_address(void)
9786 char *sock_addr = Globals.szSocketAddress;
9788 if (sock_addr[0] == '\0'){
9789 string_set(&Globals.szSocketAddress, "0.0.0.0");
9791 return Globals.szSocketAddress;
9794 void lp_set_passdb_backend(const char *backend)
9796 string_set(&Globals.szPassdbBackend, backend);