error-codes: add some more WERRORs to table.
[Samba.git] / source3 / param / loadparm.c
blob08cd80012faaa744d58b533510a8396d9a1f6e48
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 bool bLoaded = False;
59 extern enum protocol_types Protocol;
60 extern userdom_struct current_user_info;
62 #ifndef GLOBAL_NAME
63 #define GLOBAL_NAME "global"
64 #endif
66 #ifndef PRINTERS_NAME
67 #define PRINTERS_NAME "printers"
68 #endif
70 #ifndef HOMES_NAME
71 #define HOMES_NAME "homes"
72 #endif
74 /* the special value for the include parameter
75 * to be interpreted not as a file name but to
76 * trigger loading of the global smb.conf options
77 * from registry. */
78 #ifndef INCLUDE_REGISTRY_NAME
79 #define INCLUDE_REGISTRY_NAME "registry"
80 #endif
82 static bool in_client = False; /* Not in the client by default */
83 static struct smbconf_csn conf_last_csn;
85 #define CONFIG_BACKEND_FILE 0
86 #define CONFIG_BACKEND_REGISTRY 1
88 static int config_backend = CONFIG_BACKEND_FILE;
90 /* some helpful bits */
91 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
92 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
94 #define USERSHARE_VALID 1
95 #define USERSHARE_PENDING_DELETE 2
97 static bool defaults_saved = False;
99 struct param_opt_struct {
100 struct param_opt_struct *prev, *next;
101 char *key;
102 char *value;
103 char **list;
107 * This structure describes global (ie., server-wide) parameters.
109 struct global {
110 int ConfigBackend;
111 char *smb_ports;
112 char *dos_charset;
113 char *unix_charset;
114 char *display_charset;
115 char *szPrintcapname;
116 char *szAddPortCommand;
117 char *szEnumPortsCommand;
118 char *szAddPrinterCommand;
119 char *szDeletePrinterCommand;
120 char *szOs2DriverMap;
121 char *szLockDir;
122 char *szStateDir;
123 char *szCacheDir;
124 char *szPidDir;
125 char *szRootdir;
126 char *szDefaultService;
127 char *szGetQuota;
128 char *szSetQuota;
129 char *szMsgCommand;
130 char *szServerString;
131 char *szAutoServices;
132 char *szPasswdProgram;
133 char *szPasswdChat;
134 char *szLogFile;
135 char *szConfigFile;
136 char *szSMBPasswdFile;
137 char *szPrivateDir;
138 char *szPassdbBackend;
139 char **szPreloadModules;
140 char *szPasswordServer;
141 char *szSocketOptions;
142 char *szRealm;
143 char *szAfsUsernameMap;
144 int iAfsTokenLifetime;
145 char *szLogNtTokenCommand;
146 char *szUsernameMap;
147 char *szLogonScript;
148 char *szLogonPath;
149 char *szLogonDrive;
150 char *szLogonHome;
151 char **szWINSservers;
152 char **szInterfaces;
153 char *szRemoteAnnounce;
154 char *szRemoteBrowseSync;
155 char *szSocketAddress;
156 char *szNISHomeMapName;
157 char *szAnnounceVersion; /* This is initialised in init_globals */
158 char *szWorkgroup;
159 char *szNetbiosName;
160 char **szNetbiosAliases;
161 char *szNetbiosScope;
162 char *szNameResolveOrder;
163 char *szPanicAction;
164 char *szAddUserScript;
165 char *szRenameUserScript;
166 char *szDelUserScript;
167 char *szAddGroupScript;
168 char *szDelGroupScript;
169 char *szAddUserToGroupScript;
170 char *szDelUserFromGroupScript;
171 char *szSetPrimaryGroupScript;
172 char *szAddMachineScript;
173 char *szShutdownScript;
174 char *szAbortShutdownScript;
175 char *szUsernameMapScript;
176 char *szCheckPasswordScript;
177 char *szWINSHook;
178 char *szUtmpDir;
179 char *szWtmpDir;
180 bool bUtmp;
181 char *szIdmapUID;
182 char *szIdmapGID;
183 bool bPassdbExpandExplicit;
184 int AlgorithmicRidBase;
185 char *szTemplateHomedir;
186 char *szTemplateShell;
187 char *szWinbindSeparator;
188 bool bWinbindEnumUsers;
189 bool bWinbindEnumGroups;
190 bool bWinbindUseDefaultDomain;
191 bool bWinbindTrustedDomainsOnly;
192 bool bWinbindNestedGroups;
193 int winbind_expand_groups;
194 bool bWinbindRefreshTickets;
195 bool bWinbindOfflineLogon;
196 bool bWinbindNormalizeNames;
197 bool bWinbindRpcOnly;
198 char *szIdmapBackend;
199 char *szIdmapAllocBackend;
200 char *szAddShareCommand;
201 char *szChangeShareCommand;
202 char *szDeleteShareCommand;
203 char **szEventLogs;
204 char *szGuestaccount;
205 char *szManglingMethod;
206 char **szServicesList;
207 char *szUsersharePath;
208 char *szUsershareTemplateShare;
209 char **szUsersharePrefixAllowList;
210 char **szUsersharePrefixDenyList;
211 int mangle_prefix;
212 int max_log_size;
213 char *szLogLevel;
214 int max_xmit;
215 int max_mux;
216 int max_open_files;
217 int open_files_db_hash_size;
218 int pwordlevel;
219 int unamelevel;
220 int deadtime;
221 bool getwd_cache;
222 int maxprotocol;
223 int minprotocol;
224 int security;
225 char **AuthMethods;
226 bool paranoid_server_security;
227 int maxdisksize;
228 int lpqcachetime;
229 int iMaxSmbdProcesses;
230 bool bDisableSpoolss;
231 int syslog;
232 int os_level;
233 bool enhanced_browsing;
234 int max_ttl;
235 int max_wins_ttl;
236 int min_wins_ttl;
237 int lm_announce;
238 int lm_interval;
239 int announce_as; /* This is initialised in init_globals */
240 int machine_password_timeout;
241 int map_to_guest;
242 int oplock_break_wait_time;
243 int winbind_cache_time;
244 int winbind_reconnect_delay;
245 int winbind_max_idle_children;
246 char **szWinbindNssInfo;
247 int iLockSpinTime;
248 char *szLdapMachineSuffix;
249 char *szLdapUserSuffix;
250 char *szLdapIdmapSuffix;
251 char *szLdapGroupSuffix;
252 int ldap_ssl;
253 bool ldap_ssl_ads;
254 char *szLdapSuffix;
255 char *szLdapAdminDn;
256 int ldap_debug_level;
257 int ldap_debug_threshold;
258 int iAclCompat;
259 char *szCupsServer;
260 char *szIPrintServer;
261 char *ctdbdSocket;
262 char **szClusterAddresses;
263 bool clustering;
264 int ldap_passwd_sync;
265 int ldap_replication_sleep;
266 int ldap_timeout; /* This is initialised in init_globals */
267 int ldap_connection_timeout;
268 int ldap_page_size;
269 bool ldap_delete_dn;
270 bool bMsAddPrinterWizard;
271 bool bDNSproxy;
272 bool bWINSsupport;
273 bool bWINSproxy;
274 bool bLocalMaster;
275 int iPreferredMaster;
276 int iDomainMaster;
277 bool bDomainLogons;
278 char **szInitLogonDelayedHosts;
279 int InitLogonDelay;
280 bool bEncryptPasswords;
281 bool bUpdateEncrypt;
282 int clientSchannel;
283 int serverSchannel;
284 bool bNullPasswords;
285 bool bObeyPamRestrictions;
286 bool bLoadPrinters;
287 int PrintcapCacheTime;
288 bool bLargeReadwrite;
289 bool bReadRaw;
290 bool bWriteRaw;
291 bool bSyslogOnly;
292 bool bBrowseList;
293 bool bNISHomeMap;
294 bool bTimeServer;
295 bool bBindInterfacesOnly;
296 bool bPamPasswordChange;
297 bool bUnixPasswdSync;
298 bool bPasswdChatDebug;
299 int iPasswdChatTimeout;
300 bool bTimestampLogs;
301 bool bNTSmbSupport;
302 bool bNTPipeSupport;
303 bool bNTStatusSupport;
304 bool bStatCache;
305 int iMaxStatCacheSize;
306 bool bKernelOplocks;
307 bool bAllowTrustedDomains;
308 bool bLanmanAuth;
309 bool bNTLMAuth;
310 bool bUseSpnego;
311 bool bClientLanManAuth;
312 bool bClientNTLMv2Auth;
313 bool bClientPlaintextAuth;
314 bool bClientUseSpnego;
315 bool bDebugPrefixTimestamp;
316 bool bDebugHiresTimestamp;
317 bool bDebugPid;
318 bool bDebugUid;
319 bool bDebugClass;
320 bool bEnableCoreFiles;
321 bool bHostMSDfs;
322 bool bUseMmap;
323 bool bHostnameLookups;
324 bool bUnixExtensions;
325 bool bDisableNetbios;
326 char * szDedicatedKeytabFile;
327 int iKerberosMethod;
328 bool bDeferSharingViolations;
329 bool bEnablePrivileges;
330 bool bASUSupport;
331 bool bUsershareOwnerOnly;
332 bool bUsershareAllowGuests;
333 bool bRegistryShares;
334 int restrict_anonymous;
335 int name_cache_timeout;
336 int client_signing;
337 int server_signing;
338 int client_ldap_sasl_wrapping;
339 int iUsershareMaxShares;
340 int iIdmapCacheTime;
341 int iIdmapNegativeCacheTime;
342 bool bResetOnZeroVC;
343 int iKeepalive;
344 int iminreceivefile;
345 struct param_opt_struct *param_opt;
346 int cups_connection_timeout;
347 char *szSMBPerfcountModule;
348 bool bMapUntrustedToDomain;
351 static struct global Globals;
354 * This structure describes a single service.
356 struct service {
357 bool valid;
358 bool autoloaded;
359 int usershare;
360 time_t usershare_last_mod;
361 char *szService;
362 char *szPath;
363 char *szUsername;
364 char **szInvalidUsers;
365 char **szValidUsers;
366 char **szAdminUsers;
367 char *szCopy;
368 char *szInclude;
369 char *szPreExec;
370 char *szPostExec;
371 char *szRootPreExec;
372 char *szRootPostExec;
373 char *szCupsOptions;
374 char *szPrintcommand;
375 char *szLpqcommand;
376 char *szLprmcommand;
377 char *szLppausecommand;
378 char *szLpresumecommand;
379 char *szQueuepausecommand;
380 char *szQueueresumecommand;
381 char *szPrintername;
382 char *szPrintjobUsername;
383 char *szDontdescend;
384 char **szHostsallow;
385 char **szHostsdeny;
386 char *szMagicScript;
387 char *szMagicOutput;
388 char *szVetoFiles;
389 char *szHideFiles;
390 char *szVetoOplockFiles;
391 char *comment;
392 char *force_user;
393 char *force_group;
394 char **readlist;
395 char **writelist;
396 char **printer_admin;
397 char *volume;
398 char *fstype;
399 char **szVfsObjects;
400 char *szMSDfsProxy;
401 char *szAioWriteBehind;
402 char *szDfree;
403 int iMinPrintSpace;
404 int iMaxPrintJobs;
405 int iMaxReportedPrintJobs;
406 int iWriteCacheSize;
407 int iCreate_mask;
408 int iCreate_force_mode;
409 int iSecurity_mask;
410 int iSecurity_force_mode;
411 int iDir_mask;
412 int iDir_force_mode;
413 int iDir_Security_mask;
414 int iDir_Security_force_mode;
415 int iMaxConnections;
416 int iDefaultCase;
417 int iPrinting;
418 int iOplockContentionLimit;
419 int iCSCPolicy;
420 int iBlock_size;
421 int iDfreeCacheTime;
422 bool bPreexecClose;
423 bool bRootpreexecClose;
424 int iCaseSensitive;
425 bool bCasePreserve;
426 bool bShortCasePreserve;
427 bool bHideDotFiles;
428 bool bHideSpecialFiles;
429 bool bHideUnReadable;
430 bool bHideUnWriteableFiles;
431 bool bBrowseable;
432 bool bAccessBasedShareEnum;
433 bool bAvailable;
434 bool bRead_only;
435 bool bNo_set_dir;
436 bool bGuest_only;
437 bool bAdministrative_share;
438 bool bGuest_ok;
439 bool bPrint_ok;
440 bool bMap_system;
441 bool bMap_hidden;
442 bool bMap_archive;
443 bool bStoreDosAttributes;
444 bool bDmapiSupport;
445 bool bLocking;
446 int iStrictLocking;
447 bool bPosixLocking;
448 bool bShareModes;
449 bool bOpLocks;
450 bool bLevel2OpLocks;
451 bool bOnlyUser;
452 bool bMangledNames;
453 bool bWidelinks;
454 bool bSymlinks;
455 bool bSyncAlways;
456 bool bStrictAllocate;
457 bool bStrictSync;
458 char magic_char;
459 struct bitmap *copymap;
460 bool bDeleteReadonly;
461 bool bFakeOplocks;
462 bool bDeleteVetoFiles;
463 bool bDosFilemode;
464 bool bDosFiletimes;
465 bool bDosFiletimeResolution;
466 bool bFakeDirCreateTimes;
467 bool bBlockingLocks;
468 bool bInheritPerms;
469 bool bInheritACLS;
470 bool bInheritOwner;
471 bool bMSDfsRoot;
472 bool bUseClientDriver;
473 bool bDefaultDevmode;
474 bool bForcePrintername;
475 bool bNTAclSupport;
476 bool bForceUnknownAclUser;
477 bool bUseSendfile;
478 bool bProfileAcls;
479 bool bMap_acl_inherit;
480 bool bAfs_Share;
481 bool bEASupport;
482 bool bAclCheckPermissions;
483 bool bAclMapFullControl;
484 bool bAclGroupControl;
485 bool bChangeNotify;
486 bool bKernelChangeNotify;
487 int iallocation_roundup_size;
488 int iAioReadSize;
489 int iAioWriteSize;
490 int iMap_readonly;
491 int iDirectoryNameCacheSize;
492 int ismb_encrypt;
493 struct param_opt_struct *param_opt;
495 char dummy[3]; /* for alignment */
499 /* This is a default service used to prime a services structure */
500 static struct service sDefault = {
501 True, /* valid */
502 False, /* not autoloaded */
503 0, /* not a usershare */
504 (time_t)0, /* No last mod time */
505 NULL, /* szService */
506 NULL, /* szPath */
507 NULL, /* szUsername */
508 NULL, /* szInvalidUsers */
509 NULL, /* szValidUsers */
510 NULL, /* szAdminUsers */
511 NULL, /* szCopy */
512 NULL, /* szInclude */
513 NULL, /* szPreExec */
514 NULL, /* szPostExec */
515 NULL, /* szRootPreExec */
516 NULL, /* szRootPostExec */
517 NULL, /* szCupsOptions */
518 NULL, /* szPrintcommand */
519 NULL, /* szLpqcommand */
520 NULL, /* szLprmcommand */
521 NULL, /* szLppausecommand */
522 NULL, /* szLpresumecommand */
523 NULL, /* szQueuepausecommand */
524 NULL, /* szQueueresumecommand */
525 NULL, /* szPrintername */
526 NULL, /* szPrintjobUsername */
527 NULL, /* szDontdescend */
528 NULL, /* szHostsallow */
529 NULL, /* szHostsdeny */
530 NULL, /* szMagicScript */
531 NULL, /* szMagicOutput */
532 NULL, /* szVetoFiles */
533 NULL, /* szHideFiles */
534 NULL, /* szVetoOplockFiles */
535 NULL, /* comment */
536 NULL, /* force user */
537 NULL, /* force group */
538 NULL, /* readlist */
539 NULL, /* writelist */
540 NULL, /* printer admin */
541 NULL, /* volume */
542 NULL, /* fstype */
543 NULL, /* vfs objects */
544 NULL, /* szMSDfsProxy */
545 NULL, /* szAioWriteBehind */
546 NULL, /* szDfree */
547 0, /* iMinPrintSpace */
548 1000, /* iMaxPrintJobs */
549 0, /* iMaxReportedPrintJobs */
550 0, /* iWriteCacheSize */
551 0744, /* iCreate_mask */
552 0000, /* iCreate_force_mode */
553 0777, /* iSecurity_mask */
554 0, /* iSecurity_force_mode */
555 0755, /* iDir_mask */
556 0000, /* iDir_force_mode */
557 0777, /* iDir_Security_mask */
558 0, /* iDir_Security_force_mode */
559 0, /* iMaxConnections */
560 CASE_LOWER, /* iDefaultCase */
561 DEFAULT_PRINTING, /* iPrinting */
562 2, /* iOplockContentionLimit */
563 0, /* iCSCPolicy */
564 1024, /* iBlock_size */
565 0, /* iDfreeCacheTime */
566 False, /* bPreexecClose */
567 False, /* bRootpreexecClose */
568 Auto, /* case sensitive */
569 True, /* case preserve */
570 True, /* short case preserve */
571 True, /* bHideDotFiles */
572 False, /* bHideSpecialFiles */
573 False, /* bHideUnReadable */
574 False, /* bHideUnWriteableFiles */
575 True, /* bBrowseable */
576 False, /* bAccessBasedShareEnum */
577 True, /* bAvailable */
578 True, /* bRead_only */
579 True, /* bNo_set_dir */
580 False, /* bGuest_only */
581 False, /* bAdministrative_share */
582 False, /* bGuest_ok */
583 False, /* bPrint_ok */
584 False, /* bMap_system */
585 False, /* bMap_hidden */
586 True, /* bMap_archive */
587 False, /* bStoreDosAttributes */
588 False, /* bDmapiSupport */
589 True, /* bLocking */
590 Auto, /* iStrictLocking */
591 True, /* bPosixLocking */
592 True, /* bShareModes */
593 True, /* bOpLocks */
594 True, /* bLevel2OpLocks */
595 False, /* bOnlyUser */
596 True, /* bMangledNames */
597 True, /* bWidelinks */
598 True, /* bSymlinks */
599 False, /* bSyncAlways */
600 False, /* bStrictAllocate */
601 False, /* bStrictSync */
602 '~', /* magic char */
603 NULL, /* copymap */
604 False, /* bDeleteReadonly */
605 False, /* bFakeOplocks */
606 False, /* bDeleteVetoFiles */
607 False, /* bDosFilemode */
608 True, /* bDosFiletimes */
609 False, /* bDosFiletimeResolution */
610 False, /* bFakeDirCreateTimes */
611 True, /* bBlockingLocks */
612 False, /* bInheritPerms */
613 False, /* bInheritACLS */
614 False, /* bInheritOwner */
615 False, /* bMSDfsRoot */
616 False, /* bUseClientDriver */
617 True, /* bDefaultDevmode */
618 False, /* bForcePrintername */
619 True, /* bNTAclSupport */
620 False, /* bForceUnknownAclUser */
621 False, /* bUseSendfile */
622 False, /* bProfileAcls */
623 False, /* bMap_acl_inherit */
624 False, /* bAfs_Share */
625 False, /* bEASupport */
626 True, /* bAclCheckPermissions */
627 True, /* bAclMapFullControl */
628 False, /* bAclGroupControl */
629 True, /* bChangeNotify */
630 True, /* bKernelChangeNotify */
631 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
632 0, /* iAioReadSize */
633 0, /* iAioWriteSize */
634 MAP_READONLY_YES, /* iMap_readonly */
635 #ifdef BROKEN_DIRECTORY_HANDLING
636 0, /* iDirectoryNameCacheSize */
637 #else
638 100, /* iDirectoryNameCacheSize */
639 #endif
640 Auto, /* ismb_encrypt */
641 NULL, /* Parametric options */
643 "" /* dummy */
646 /* local variables */
647 static struct service **ServicePtrs = NULL;
648 static int iNumServices = 0;
649 static int iServiceIndex = 0;
650 static struct db_context *ServiceHash;
651 static int *invalid_services = NULL;
652 static int num_invalid_services = 0;
653 static bool bInGlobalSection = True;
654 static bool bGlobalOnly = False;
655 static int server_role;
656 static int default_server_announce;
658 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
660 /* prototypes for the special type handlers */
661 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
662 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
663 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
664 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
665 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
666 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
667 static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
668 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
669 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
670 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
671 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
672 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
674 static void set_server_role(void);
675 static void set_default_server_announce_type(void);
676 static void set_allowed_client_auth(void);
678 static void *lp_local_ptr(struct service *service, void *ptr);
680 static void add_to_file_list(const char *fname, const char *subfname);
682 static const struct enum_list enum_protocol[] = {
683 {PROTOCOL_NT1, "NT1"},
684 {PROTOCOL_LANMAN2, "LANMAN2"},
685 {PROTOCOL_LANMAN1, "LANMAN1"},
686 {PROTOCOL_CORE, "CORE"},
687 {PROTOCOL_COREPLUS, "COREPLUS"},
688 {PROTOCOL_COREPLUS, "CORE+"},
689 {-1, NULL}
692 static const struct enum_list enum_security[] = {
693 {SEC_SHARE, "SHARE"},
694 {SEC_USER, "USER"},
695 {SEC_SERVER, "SERVER"},
696 {SEC_DOMAIN, "DOMAIN"},
697 #ifdef HAVE_ADS
698 {SEC_ADS, "ADS"},
699 #endif
700 {-1, NULL}
703 static const struct enum_list enum_printing[] = {
704 {PRINT_SYSV, "sysv"},
705 {PRINT_AIX, "aix"},
706 {PRINT_HPUX, "hpux"},
707 {PRINT_BSD, "bsd"},
708 {PRINT_QNX, "qnx"},
709 {PRINT_PLP, "plp"},
710 {PRINT_LPRNG, "lprng"},
711 {PRINT_CUPS, "cups"},
712 {PRINT_IPRINT, "iprint"},
713 {PRINT_LPRNT, "nt"},
714 {PRINT_LPROS2, "os2"},
715 #ifdef DEVELOPER
716 {PRINT_TEST, "test"},
717 {PRINT_VLP, "vlp"},
718 #endif /* DEVELOPER */
719 {-1, NULL}
722 static const struct enum_list enum_ldap_sasl_wrapping[] = {
723 {0, "plain"},
724 {ADS_AUTH_SASL_SIGN, "sign"},
725 {ADS_AUTH_SASL_SEAL, "seal"},
726 {-1, NULL}
729 static const struct enum_list enum_ldap_ssl[] = {
730 {LDAP_SSL_OFF, "no"},
731 {LDAP_SSL_OFF, "off"},
732 {LDAP_SSL_START_TLS, "start tls"},
733 {LDAP_SSL_START_TLS, "start_tls"},
734 {-1, NULL}
737 static const struct enum_list enum_ldap_passwd_sync[] = {
738 {LDAP_PASSWD_SYNC_OFF, "no"},
739 {LDAP_PASSWD_SYNC_OFF, "off"},
740 {LDAP_PASSWD_SYNC_ON, "yes"},
741 {LDAP_PASSWD_SYNC_ON, "on"},
742 {LDAP_PASSWD_SYNC_ONLY, "only"},
743 {-1, NULL}
746 /* Types of machine we can announce as. */
747 #define ANNOUNCE_AS_NT_SERVER 1
748 #define ANNOUNCE_AS_WIN95 2
749 #define ANNOUNCE_AS_WFW 3
750 #define ANNOUNCE_AS_NT_WORKSTATION 4
752 static const struct enum_list enum_announce_as[] = {
753 {ANNOUNCE_AS_NT_SERVER, "NT"},
754 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
755 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
756 {ANNOUNCE_AS_WIN95, "win95"},
757 {ANNOUNCE_AS_WFW, "WfW"},
758 {-1, NULL}
761 static const struct enum_list enum_map_readonly[] = {
762 {MAP_READONLY_NO, "no"},
763 {MAP_READONLY_NO, "false"},
764 {MAP_READONLY_NO, "0"},
765 {MAP_READONLY_YES, "yes"},
766 {MAP_READONLY_YES, "true"},
767 {MAP_READONLY_YES, "1"},
768 {MAP_READONLY_PERMISSIONS, "permissions"},
769 {MAP_READONLY_PERMISSIONS, "perms"},
770 {-1, NULL}
773 static const struct enum_list enum_case[] = {
774 {CASE_LOWER, "lower"},
775 {CASE_UPPER, "upper"},
776 {-1, NULL}
779 static const struct enum_list enum_bool_auto[] = {
780 {False, "No"},
781 {False, "False"},
782 {False, "0"},
783 {True, "Yes"},
784 {True, "True"},
785 {True, "1"},
786 {Auto, "Auto"},
787 {-1, NULL}
790 /* Client-side offline caching policy types */
791 #define CSC_POLICY_MANUAL 0
792 #define CSC_POLICY_DOCUMENTS 1
793 #define CSC_POLICY_PROGRAMS 2
794 #define CSC_POLICY_DISABLE 3
796 static const struct enum_list enum_csc_policy[] = {
797 {CSC_POLICY_MANUAL, "manual"},
798 {CSC_POLICY_DOCUMENTS, "documents"},
799 {CSC_POLICY_PROGRAMS, "programs"},
800 {CSC_POLICY_DISABLE, "disable"},
801 {-1, NULL}
804 /* SMB signing types. */
805 static const struct enum_list enum_smb_signing_vals[] = {
806 {False, "No"},
807 {False, "False"},
808 {False, "0"},
809 {False, "Off"},
810 {False, "disabled"},
811 {True, "Yes"},
812 {True, "True"},
813 {True, "1"},
814 {True, "On"},
815 {True, "enabled"},
816 {Auto, "auto"},
817 {Required, "required"},
818 {Required, "mandatory"},
819 {Required, "force"},
820 {Required, "forced"},
821 {Required, "enforced"},
822 {-1, NULL}
825 /* ACL compatibility options. */
826 static const struct enum_list enum_acl_compat_vals[] = {
827 { ACL_COMPAT_AUTO, "auto" },
828 { ACL_COMPAT_WINNT, "winnt" },
829 { ACL_COMPAT_WIN2K, "win2k" },
830 { -1, NULL}
834 Do you want session setups at user level security with a invalid
835 password to be rejected or allowed in as guest? WinNT rejects them
836 but it can be a pain as it means "net view" needs to use a password
838 You have 3 choices in the setting of map_to_guest:
840 "Never" means session setups with an invalid password
841 are rejected. This is the default.
843 "Bad User" means session setups with an invalid password
844 are rejected, unless the username does not exist, in which case it
845 is treated as a guest login
847 "Bad Password" means session setups with an invalid password
848 are treated as a guest login
850 Note that map_to_guest only has an effect in user or server
851 level security.
854 static const struct enum_list enum_map_to_guest[] = {
855 {NEVER_MAP_TO_GUEST, "Never"},
856 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
857 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
858 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
859 {-1, NULL}
862 /* Config backend options */
864 static const struct enum_list enum_config_backend[] = {
865 {CONFIG_BACKEND_FILE, "file"},
866 {CONFIG_BACKEND_REGISTRY, "registry"},
867 {-1, NULL}
870 /* ADS kerberos ticket verification options */
872 static const struct enum_list enum_kerberos_method[] = {
873 {KERBEROS_VERIFY_SECRETS, "default"},
874 {KERBEROS_VERIFY_SECRETS, "secrets only"},
875 {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
876 {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
877 {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
878 {-1, NULL}
881 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
883 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
884 * screen in SWAT. This is used to exclude parameters as well as to squash all
885 * parameters that have been duplicated by pseudonyms.
887 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
888 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
889 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
890 * respective views.
892 * NOTE2: Handling of duplicated (synonym) parameters:
893 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
894 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
895 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
896 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
899 static struct parm_struct parm_table[] = {
900 {N_("Base Options"), P_SEP, P_SEPARATOR},
903 .label = "dos charset",
904 .type = P_STRING,
905 .p_class = P_GLOBAL,
906 .ptr = &Globals.dos_charset,
907 .special = handle_charset,
908 .enum_list = NULL,
909 .flags = FLAG_ADVANCED
912 .label = "unix charset",
913 .type = P_STRING,
914 .p_class = P_GLOBAL,
915 .ptr = &Globals.unix_charset,
916 .special = handle_charset,
917 .enum_list = NULL,
918 .flags = FLAG_ADVANCED
921 .label = "display charset",
922 .type = P_STRING,
923 .p_class = P_GLOBAL,
924 .ptr = &Globals.display_charset,
925 .special = handle_charset,
926 .enum_list = NULL,
927 .flags = FLAG_ADVANCED
930 .label = "comment",
931 .type = P_STRING,
932 .p_class = P_LOCAL,
933 .ptr = &sDefault.comment,
934 .special = NULL,
935 .enum_list = NULL,
936 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
939 .label = "path",
940 .type = P_STRING,
941 .p_class = P_LOCAL,
942 .ptr = &sDefault.szPath,
943 .special = NULL,
944 .enum_list = NULL,
945 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
948 .label = "directory",
949 .type = P_STRING,
950 .p_class = P_LOCAL,
951 .ptr = &sDefault.szPath,
952 .special = NULL,
953 .enum_list = NULL,
954 .flags = FLAG_HIDE,
957 .label = "workgroup",
958 .type = P_USTRING,
959 .p_class = P_GLOBAL,
960 .ptr = &Globals.szWorkgroup,
961 .special = handle_workgroup,
962 .enum_list = NULL,
963 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
965 #ifdef WITH_ADS
967 .label = "realm",
968 .type = P_USTRING,
969 .p_class = P_GLOBAL,
970 .ptr = &Globals.szRealm,
971 .special = NULL,
972 .enum_list = NULL,
973 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
975 #endif
977 .label = "netbios name",
978 .type = P_USTRING,
979 .p_class = P_GLOBAL,
980 .ptr = &Globals.szNetbiosName,
981 .special = handle_netbios_name,
982 .enum_list = NULL,
983 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
986 .label = "netbios aliases",
987 .type = P_LIST,
988 .p_class = P_GLOBAL,
989 .ptr = &Globals.szNetbiosAliases,
990 .special = handle_netbios_aliases,
991 .enum_list = NULL,
992 .flags = FLAG_ADVANCED,
995 .label = "netbios scope",
996 .type = P_USTRING,
997 .p_class = P_GLOBAL,
998 .ptr = &Globals.szNetbiosScope,
999 .special = handle_netbios_scope,
1000 .enum_list = NULL,
1001 .flags = FLAG_ADVANCED,
1004 .label = "server string",
1005 .type = P_STRING,
1006 .p_class = P_GLOBAL,
1007 .ptr = &Globals.szServerString,
1008 .special = NULL,
1009 .enum_list = NULL,
1010 .flags = FLAG_BASIC | FLAG_ADVANCED,
1013 .label = "interfaces",
1014 .type = P_LIST,
1015 .p_class = P_GLOBAL,
1016 .ptr = &Globals.szInterfaces,
1017 .special = NULL,
1018 .enum_list = NULL,
1019 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1022 .label = "bind interfaces only",
1023 .type = P_BOOL,
1024 .p_class = P_GLOBAL,
1025 .ptr = &Globals.bBindInterfacesOnly,
1026 .special = NULL,
1027 .enum_list = NULL,
1028 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1031 .label = "config backend",
1032 .type = P_ENUM,
1033 .p_class = P_GLOBAL,
1034 .ptr = &Globals.ConfigBackend,
1035 .special = NULL,
1036 .enum_list = enum_config_backend,
1037 .flags = FLAG_ADVANCED,
1040 {N_("Security Options"), P_SEP, P_SEPARATOR},
1043 .label = "security",
1044 .type = P_ENUM,
1045 .p_class = P_GLOBAL,
1046 .ptr = &Globals.security,
1047 .special = NULL,
1048 .enum_list = enum_security,
1049 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1052 .label = "auth methods",
1053 .type = P_LIST,
1054 .p_class = P_GLOBAL,
1055 .ptr = &Globals.AuthMethods,
1056 .special = NULL,
1057 .enum_list = NULL,
1058 .flags = FLAG_ADVANCED,
1061 .label = "encrypt passwords",
1062 .type = P_BOOL,
1063 .p_class = P_GLOBAL,
1064 .ptr = &Globals.bEncryptPasswords,
1065 .special = NULL,
1066 .enum_list = NULL,
1067 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1070 .label = "update encrypted",
1071 .type = P_BOOL,
1072 .p_class = P_GLOBAL,
1073 .ptr = &Globals.bUpdateEncrypt,
1074 .special = NULL,
1075 .enum_list = NULL,
1076 .flags = FLAG_ADVANCED,
1079 .label = "client schannel",
1080 .type = P_ENUM,
1081 .p_class = P_GLOBAL,
1082 .ptr = &Globals.clientSchannel,
1083 .special = NULL,
1084 .enum_list = enum_bool_auto,
1085 .flags = FLAG_BASIC | FLAG_ADVANCED,
1088 .label = "server schannel",
1089 .type = P_ENUM,
1090 .p_class = P_GLOBAL,
1091 .ptr = &Globals.serverSchannel,
1092 .special = NULL,
1093 .enum_list = enum_bool_auto,
1094 .flags = FLAG_BASIC | FLAG_ADVANCED,
1097 .label = "allow trusted domains",
1098 .type = P_BOOL,
1099 .p_class = P_GLOBAL,
1100 .ptr = &Globals.bAllowTrustedDomains,
1101 .special = NULL,
1102 .enum_list = NULL,
1103 .flags = FLAG_ADVANCED,
1106 .label = "map to guest",
1107 .type = P_ENUM,
1108 .p_class = P_GLOBAL,
1109 .ptr = &Globals.map_to_guest,
1110 .special = NULL,
1111 .enum_list = enum_map_to_guest,
1112 .flags = FLAG_ADVANCED,
1115 .label = "null passwords",
1116 .type = P_BOOL,
1117 .p_class = P_GLOBAL,
1118 .ptr = &Globals.bNullPasswords,
1119 .special = NULL,
1120 .enum_list = NULL,
1121 .flags = FLAG_ADVANCED,
1124 .label = "obey pam restrictions",
1125 .type = P_BOOL,
1126 .p_class = P_GLOBAL,
1127 .ptr = &Globals.bObeyPamRestrictions,
1128 .special = NULL,
1129 .enum_list = NULL,
1130 .flags = FLAG_ADVANCED,
1133 .label = "password server",
1134 .type = P_STRING,
1135 .p_class = P_GLOBAL,
1136 .ptr = &Globals.szPasswordServer,
1137 .special = NULL,
1138 .enum_list = NULL,
1139 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1142 .label = "smb passwd file",
1143 .type = P_STRING,
1144 .p_class = P_GLOBAL,
1145 .ptr = &Globals.szSMBPasswdFile,
1146 .special = NULL,
1147 .enum_list = NULL,
1148 .flags = FLAG_ADVANCED,
1151 .label = "private dir",
1152 .type = P_STRING,
1153 .p_class = P_GLOBAL,
1154 .ptr = &Globals.szPrivateDir,
1155 .special = NULL,
1156 .enum_list = NULL,
1157 .flags = FLAG_ADVANCED,
1160 .label = "passdb backend",
1161 .type = P_STRING,
1162 .p_class = P_GLOBAL,
1163 .ptr = &Globals.szPassdbBackend,
1164 .special = NULL,
1165 .enum_list = NULL,
1166 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1169 .label = "algorithmic rid base",
1170 .type = P_INTEGER,
1171 .p_class = P_GLOBAL,
1172 .ptr = &Globals.AlgorithmicRidBase,
1173 .special = NULL,
1174 .enum_list = NULL,
1175 .flags = FLAG_ADVANCED,
1178 .label = "root directory",
1179 .type = P_STRING,
1180 .p_class = P_GLOBAL,
1181 .ptr = &Globals.szRootdir,
1182 .special = NULL,
1183 .enum_list = NULL,
1184 .flags = FLAG_ADVANCED,
1187 .label = "root dir",
1188 .type = P_STRING,
1189 .p_class = P_GLOBAL,
1190 .ptr = &Globals.szRootdir,
1191 .special = NULL,
1192 .enum_list = NULL,
1193 .flags = FLAG_HIDE,
1196 .label = "root",
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 = "guest account",
1206 .type = P_STRING,
1207 .p_class = P_GLOBAL,
1208 .ptr = &Globals.szGuestaccount,
1209 .special = NULL,
1210 .enum_list = NULL,
1211 .flags = FLAG_BASIC | FLAG_ADVANCED,
1214 .label = "enable privileges",
1215 .type = P_BOOL,
1216 .p_class = P_GLOBAL,
1217 .ptr = &Globals.bEnablePrivileges,
1218 .special = NULL,
1219 .enum_list = NULL,
1220 .flags = FLAG_ADVANCED,
1224 .label = "pam password change",
1225 .type = P_BOOL,
1226 .p_class = P_GLOBAL,
1227 .ptr = &Globals.bPamPasswordChange,
1228 .special = NULL,
1229 .enum_list = NULL,
1230 .flags = FLAG_ADVANCED,
1233 .label = "passwd program",
1234 .type = P_STRING,
1235 .p_class = P_GLOBAL,
1236 .ptr = &Globals.szPasswdProgram,
1237 .special = NULL,
1238 .enum_list = NULL,
1239 .flags = FLAG_ADVANCED,
1242 .label = "passwd chat",
1243 .type = P_STRING,
1244 .p_class = P_GLOBAL,
1245 .ptr = &Globals.szPasswdChat,
1246 .special = NULL,
1247 .enum_list = NULL,
1248 .flags = FLAG_ADVANCED,
1251 .label = "passwd chat debug",
1252 .type = P_BOOL,
1253 .p_class = P_GLOBAL,
1254 .ptr = &Globals.bPasswdChatDebug,
1255 .special = NULL,
1256 .enum_list = NULL,
1257 .flags = FLAG_ADVANCED,
1260 .label = "passwd chat timeout",
1261 .type = P_INTEGER,
1262 .p_class = P_GLOBAL,
1263 .ptr = &Globals.iPasswdChatTimeout,
1264 .special = NULL,
1265 .enum_list = NULL,
1266 .flags = FLAG_ADVANCED,
1269 .label = "check password script",
1270 .type = P_STRING,
1271 .p_class = P_GLOBAL,
1272 .ptr = &Globals.szCheckPasswordScript,
1273 .special = NULL,
1274 .enum_list = NULL,
1275 .flags = FLAG_ADVANCED,
1278 .label = "username map",
1279 .type = P_STRING,
1280 .p_class = P_GLOBAL,
1281 .ptr = &Globals.szUsernameMap,
1282 .special = NULL,
1283 .enum_list = NULL,
1284 .flags = FLAG_ADVANCED,
1287 .label = "password level",
1288 .type = P_INTEGER,
1289 .p_class = P_GLOBAL,
1290 .ptr = &Globals.pwordlevel,
1291 .special = NULL,
1292 .enum_list = NULL,
1293 .flags = FLAG_ADVANCED,
1296 .label = "username level",
1297 .type = P_INTEGER,
1298 .p_class = P_GLOBAL,
1299 .ptr = &Globals.unamelevel,
1300 .special = NULL,
1301 .enum_list = NULL,
1302 .flags = FLAG_ADVANCED,
1305 .label = "unix password sync",
1306 .type = P_BOOL,
1307 .p_class = P_GLOBAL,
1308 .ptr = &Globals.bUnixPasswdSync,
1309 .special = NULL,
1310 .enum_list = NULL,
1311 .flags = FLAG_ADVANCED,
1314 .label = "restrict anonymous",
1315 .type = P_INTEGER,
1316 .p_class = P_GLOBAL,
1317 .ptr = &Globals.restrict_anonymous,
1318 .special = NULL,
1319 .enum_list = NULL,
1320 .flags = FLAG_ADVANCED,
1323 .label = "lanman auth",
1324 .type = P_BOOL,
1325 .p_class = P_GLOBAL,
1326 .ptr = &Globals.bLanmanAuth,
1327 .special = NULL,
1328 .enum_list = NULL,
1329 .flags = FLAG_ADVANCED,
1332 .label = "ntlm auth",
1333 .type = P_BOOL,
1334 .p_class = P_GLOBAL,
1335 .ptr = &Globals.bNTLMAuth,
1336 .special = NULL,
1337 .enum_list = NULL,
1338 .flags = FLAG_ADVANCED,
1341 .label = "client NTLMv2 auth",
1342 .type = P_BOOL,
1343 .p_class = P_GLOBAL,
1344 .ptr = &Globals.bClientNTLMv2Auth,
1345 .special = NULL,
1346 .enum_list = NULL,
1347 .flags = FLAG_ADVANCED,
1350 .label = "client lanman auth",
1351 .type = P_BOOL,
1352 .p_class = P_GLOBAL,
1353 .ptr = &Globals.bClientLanManAuth,
1354 .special = NULL,
1355 .enum_list = NULL,
1356 .flags = FLAG_ADVANCED,
1359 .label = "client plaintext auth",
1360 .type = P_BOOL,
1361 .p_class = P_GLOBAL,
1362 .ptr = &Globals.bClientPlaintextAuth,
1363 .special = NULL,
1364 .enum_list = NULL,
1365 .flags = FLAG_ADVANCED,
1368 .label = "username",
1369 .type = P_STRING,
1370 .p_class = P_LOCAL,
1371 .ptr = &sDefault.szUsername,
1372 .special = NULL,
1373 .enum_list = NULL,
1374 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1377 .label = "user",
1378 .type = P_STRING,
1379 .p_class = P_LOCAL,
1380 .ptr = &sDefault.szUsername,
1381 .special = NULL,
1382 .enum_list = NULL,
1383 .flags = FLAG_HIDE,
1386 .label = "users",
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 = "invalid users",
1396 .type = P_LIST,
1397 .p_class = P_LOCAL,
1398 .ptr = &sDefault.szInvalidUsers,
1399 .special = NULL,
1400 .enum_list = NULL,
1401 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1404 .label = "valid users",
1405 .type = P_LIST,
1406 .p_class = P_LOCAL,
1407 .ptr = &sDefault.szValidUsers,
1408 .special = NULL,
1409 .enum_list = NULL,
1410 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1413 .label = "admin users",
1414 .type = P_LIST,
1415 .p_class = P_LOCAL,
1416 .ptr = &sDefault.szAdminUsers,
1417 .special = NULL,
1418 .enum_list = NULL,
1419 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1422 .label = "read list",
1423 .type = P_LIST,
1424 .p_class = P_LOCAL,
1425 .ptr = &sDefault.readlist,
1426 .special = NULL,
1427 .enum_list = NULL,
1428 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1431 .label = "write list",
1432 .type = P_LIST,
1433 .p_class = P_LOCAL,
1434 .ptr = &sDefault.writelist,
1435 .special = NULL,
1436 .enum_list = NULL,
1437 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1440 .label = "printer admin",
1441 .type = P_LIST,
1442 .p_class = P_LOCAL,
1443 .ptr = &sDefault.printer_admin,
1444 .special = NULL,
1445 .enum_list = NULL,
1446 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1449 .label = "force user",
1450 .type = P_STRING,
1451 .p_class = P_LOCAL,
1452 .ptr = &sDefault.force_user,
1453 .special = NULL,
1454 .enum_list = NULL,
1455 .flags = FLAG_ADVANCED | FLAG_SHARE,
1458 .label = "force group",
1459 .type = P_STRING,
1460 .p_class = P_LOCAL,
1461 .ptr = &sDefault.force_group,
1462 .special = NULL,
1463 .enum_list = NULL,
1464 .flags = FLAG_ADVANCED | FLAG_SHARE,
1467 .label = "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,
1476 .label = "read only",
1477 .type = P_BOOL,
1478 .p_class = P_LOCAL,
1479 .ptr = &sDefault.bRead_only,
1480 .special = NULL,
1481 .enum_list = NULL,
1482 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1485 .label = "write ok",
1486 .type = P_BOOLREV,
1487 .p_class = P_LOCAL,
1488 .ptr = &sDefault.bRead_only,
1489 .special = NULL,
1490 .enum_list = NULL,
1491 .flags = FLAG_HIDE,
1494 .label = "writeable",
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 = "writable",
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 = "acl check permissions",
1513 .type = P_BOOL,
1514 .p_class = P_LOCAL,
1515 .ptr = &sDefault.bAclCheckPermissions,
1516 .special = NULL,
1517 .enum_list = NULL,
1518 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1521 .label = "acl group control",
1522 .type = P_BOOL,
1523 .p_class = P_LOCAL,
1524 .ptr = &sDefault.bAclGroupControl,
1525 .special = NULL,
1526 .enum_list = NULL,
1527 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1530 .label = "acl map full control",
1531 .type = P_BOOL,
1532 .p_class = P_LOCAL,
1533 .ptr = &sDefault.bAclMapFullControl,
1534 .special = NULL,
1535 .enum_list = NULL,
1536 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1539 .label = "create mask",
1540 .type = P_OCTAL,
1541 .p_class = P_LOCAL,
1542 .ptr = &sDefault.iCreate_mask,
1543 .special = NULL,
1544 .enum_list = NULL,
1545 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1548 .label = "create mode",
1549 .type = P_OCTAL,
1550 .p_class = P_LOCAL,
1551 .ptr = &sDefault.iCreate_mask,
1552 .special = NULL,
1553 .enum_list = NULL,
1554 .flags = FLAG_HIDE,
1557 .label = "force create mode",
1558 .type = P_OCTAL,
1559 .p_class = P_LOCAL,
1560 .ptr = &sDefault.iCreate_force_mode,
1561 .special = NULL,
1562 .enum_list = NULL,
1563 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1566 .label = "security mask",
1567 .type = P_OCTAL,
1568 .p_class = P_LOCAL,
1569 .ptr = &sDefault.iSecurity_mask,
1570 .special = NULL,
1571 .enum_list = NULL,
1572 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1575 .label = "force security mode",
1576 .type = P_OCTAL,
1577 .p_class = P_LOCAL,
1578 .ptr = &sDefault.iSecurity_force_mode,
1579 .special = NULL,
1580 .enum_list = NULL,
1581 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1584 .label = "directory mask",
1585 .type = P_OCTAL,
1586 .p_class = P_LOCAL,
1587 .ptr = &sDefault.iDir_mask,
1588 .special = NULL,
1589 .enum_list = NULL,
1590 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1593 .label = "directory mode",
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,
1602 .label = "force directory mode",
1603 .type = P_OCTAL,
1604 .p_class = P_LOCAL,
1605 .ptr = &sDefault.iDir_force_mode,
1606 .special = NULL,
1607 .enum_list = NULL,
1608 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1611 .label = "directory security mask",
1612 .type = P_OCTAL,
1613 .p_class = P_LOCAL,
1614 .ptr = &sDefault.iDir_Security_mask,
1615 .special = NULL,
1616 .enum_list = NULL,
1617 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1620 .label = "force directory security mode",
1621 .type = P_OCTAL,
1622 .p_class = P_LOCAL,
1623 .ptr = &sDefault.iDir_Security_force_mode,
1624 .special = NULL,
1625 .enum_list = NULL,
1626 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1629 .label = "force unknown acl user",
1630 .type = P_BOOL,
1631 .p_class = P_LOCAL,
1632 .ptr = &sDefault.bForceUnknownAclUser,
1633 .special = NULL,
1634 .enum_list = NULL,
1635 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1638 .label = "inherit permissions",
1639 .type = P_BOOL,
1640 .p_class = P_LOCAL,
1641 .ptr = &sDefault.bInheritPerms,
1642 .special = NULL,
1643 .enum_list = NULL,
1644 .flags = FLAG_ADVANCED | FLAG_SHARE,
1647 .label = "inherit acls",
1648 .type = P_BOOL,
1649 .p_class = P_LOCAL,
1650 .ptr = &sDefault.bInheritACLS,
1651 .special = NULL,
1652 .enum_list = NULL,
1653 .flags = FLAG_ADVANCED | FLAG_SHARE,
1656 .label = "inherit owner",
1657 .type = P_BOOL,
1658 .p_class = P_LOCAL,
1659 .ptr = &sDefault.bInheritOwner,
1660 .special = NULL,
1661 .enum_list = NULL,
1662 .flags = FLAG_ADVANCED | FLAG_SHARE,
1665 .label = "guest only",
1666 .type = P_BOOL,
1667 .p_class = P_LOCAL,
1668 .ptr = &sDefault.bGuest_only,
1669 .special = NULL,
1670 .enum_list = NULL,
1671 .flags = FLAG_ADVANCED | FLAG_SHARE,
1674 .label = "only guest",
1675 .type = P_BOOL,
1676 .p_class = P_LOCAL,
1677 .ptr = &sDefault.bGuest_only,
1678 .special = NULL,
1679 .enum_list = NULL,
1680 .flags = FLAG_HIDE,
1683 .label = "administrative share",
1684 .type = P_BOOL,
1685 .p_class = P_LOCAL,
1686 .ptr = &sDefault.bAdministrative_share,
1687 .special = NULL,
1688 .enum_list = NULL,
1689 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1693 .label = "guest ok",
1694 .type = P_BOOL,
1695 .p_class = P_LOCAL,
1696 .ptr = &sDefault.bGuest_ok,
1697 .special = NULL,
1698 .enum_list = NULL,
1699 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1702 .label = "public",
1703 .type = P_BOOL,
1704 .p_class = P_LOCAL,
1705 .ptr = &sDefault.bGuest_ok,
1706 .special = NULL,
1707 .enum_list = NULL,
1708 .flags = FLAG_HIDE,
1711 .label = "only user",
1712 .type = P_BOOL,
1713 .p_class = P_LOCAL,
1714 .ptr = &sDefault.bOnlyUser,
1715 .special = NULL,
1716 .enum_list = NULL,
1717 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1720 .label = "hosts allow",
1721 .type = P_LIST,
1722 .p_class = P_LOCAL,
1723 .ptr = &sDefault.szHostsallow,
1724 .special = NULL,
1725 .enum_list = NULL,
1726 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1729 .label = "allow hosts",
1730 .type = P_LIST,
1731 .p_class = P_LOCAL,
1732 .ptr = &sDefault.szHostsallow,
1733 .special = NULL,
1734 .enum_list = NULL,
1735 .flags = FLAG_HIDE,
1738 .label = "hosts deny",
1739 .type = P_LIST,
1740 .p_class = P_LOCAL,
1741 .ptr = &sDefault.szHostsdeny,
1742 .special = NULL,
1743 .enum_list = NULL,
1744 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1747 .label = "deny hosts",
1748 .type = P_LIST,
1749 .p_class = P_LOCAL,
1750 .ptr = &sDefault.szHostsdeny,
1751 .special = NULL,
1752 .enum_list = NULL,
1753 .flags = FLAG_HIDE,
1756 .label = "preload modules",
1757 .type = P_LIST,
1758 .p_class = P_GLOBAL,
1759 .ptr = &Globals.szPreloadModules,
1760 .special = NULL,
1761 .enum_list = NULL,
1762 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1765 .label = "dedicated keytab file",
1766 .type = P_STRING,
1767 .p_class = P_GLOBAL,
1768 .ptr = &Globals.szDedicatedKeytabFile,
1769 .special = NULL,
1770 .enum_list = NULL,
1771 .flags = FLAG_ADVANCED,
1774 .label = "kerberos method",
1775 .type = P_ENUM,
1776 .p_class = P_GLOBAL,
1777 .ptr = &Globals.iKerberosMethod,
1778 .special = NULL,
1779 .enum_list = enum_kerberos_method,
1780 .flags = FLAG_ADVANCED,
1783 .label = "map untrusted to domain",
1784 .type = P_BOOL,
1785 .p_class = P_GLOBAL,
1786 .ptr = &Globals.bMapUntrustedToDomain,
1787 .special = NULL,
1788 .enum_list = NULL,
1789 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1793 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1796 .label = "log level",
1797 .type = P_STRING,
1798 .p_class = P_GLOBAL,
1799 .ptr = &Globals.szLogLevel,
1800 .special = handle_debug_list,
1801 .enum_list = NULL,
1802 .flags = FLAG_ADVANCED,
1805 .label = "debuglevel",
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_HIDE,
1814 .label = "syslog",
1815 .type = P_INTEGER,
1816 .p_class = P_GLOBAL,
1817 .ptr = &Globals.syslog,
1818 .special = NULL,
1819 .enum_list = NULL,
1820 .flags = FLAG_ADVANCED,
1823 .label = "syslog only",
1824 .type = P_BOOL,
1825 .p_class = P_GLOBAL,
1826 .ptr = &Globals.bSyslogOnly,
1827 .special = NULL,
1828 .enum_list = NULL,
1829 .flags = FLAG_ADVANCED,
1832 .label = "log file",
1833 .type = P_STRING,
1834 .p_class = P_GLOBAL,
1835 .ptr = &Globals.szLogFile,
1836 .special = NULL,
1837 .enum_list = NULL,
1838 .flags = FLAG_ADVANCED,
1841 .label = "max log size",
1842 .type = P_INTEGER,
1843 .p_class = P_GLOBAL,
1844 .ptr = &Globals.max_log_size,
1845 .special = NULL,
1846 .enum_list = NULL,
1847 .flags = FLAG_ADVANCED,
1850 .label = "debug timestamp",
1851 .type = P_BOOL,
1852 .p_class = P_GLOBAL,
1853 .ptr = &Globals.bTimestampLogs,
1854 .special = NULL,
1855 .enum_list = NULL,
1856 .flags = FLAG_ADVANCED,
1859 .label = "timestamp logs",
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 = "debug prefix timestamp",
1869 .type = P_BOOL,
1870 .p_class = P_GLOBAL,
1871 .ptr = &Globals.bDebugPrefixTimestamp,
1872 .special = NULL,
1873 .enum_list = NULL,
1874 .flags = FLAG_ADVANCED,
1877 .label = "debug hires timestamp",
1878 .type = P_BOOL,
1879 .p_class = P_GLOBAL,
1880 .ptr = &Globals.bDebugHiresTimestamp,
1881 .special = NULL,
1882 .enum_list = NULL,
1883 .flags = FLAG_ADVANCED,
1886 .label = "debug pid",
1887 .type = P_BOOL,
1888 .p_class = P_GLOBAL,
1889 .ptr = &Globals.bDebugPid,
1890 .special = NULL,
1891 .enum_list = NULL,
1892 .flags = FLAG_ADVANCED,
1895 .label = "debug uid",
1896 .type = P_BOOL,
1897 .p_class = P_GLOBAL,
1898 .ptr = &Globals.bDebugUid,
1899 .special = NULL,
1900 .enum_list = NULL,
1901 .flags = FLAG_ADVANCED,
1904 .label = "debug class",
1905 .type = P_BOOL,
1906 .p_class = P_GLOBAL,
1907 .ptr = &Globals.bDebugClass,
1908 .special = NULL,
1909 .enum_list = NULL,
1910 .flags = FLAG_ADVANCED,
1913 .label = "enable core files",
1914 .type = P_BOOL,
1915 .p_class = P_GLOBAL,
1916 .ptr = &Globals.bEnableCoreFiles,
1917 .special = NULL,
1918 .enum_list = NULL,
1919 .flags = FLAG_ADVANCED,
1922 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1925 .label = "allocation roundup size",
1926 .type = P_INTEGER,
1927 .p_class = P_LOCAL,
1928 .ptr = &sDefault.iallocation_roundup_size,
1929 .special = NULL,
1930 .enum_list = NULL,
1931 .flags = FLAG_ADVANCED,
1934 .label = "aio read size",
1935 .type = P_INTEGER,
1936 .p_class = P_LOCAL,
1937 .ptr = &sDefault.iAioReadSize,
1938 .special = NULL,
1939 .enum_list = NULL,
1940 .flags = FLAG_ADVANCED,
1943 .label = "aio write size",
1944 .type = P_INTEGER,
1945 .p_class = P_LOCAL,
1946 .ptr = &sDefault.iAioWriteSize,
1947 .special = NULL,
1948 .enum_list = NULL,
1949 .flags = FLAG_ADVANCED,
1952 .label = "aio write behind",
1953 .type = P_STRING,
1954 .p_class = P_LOCAL,
1955 .ptr = &sDefault.szAioWriteBehind,
1956 .special = NULL,
1957 .enum_list = NULL,
1958 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1961 .label = "smb ports",
1962 .type = P_STRING,
1963 .p_class = P_GLOBAL,
1964 .ptr = &Globals.smb_ports,
1965 .special = NULL,
1966 .enum_list = NULL,
1967 .flags = FLAG_ADVANCED,
1970 .label = "large readwrite",
1971 .type = P_BOOL,
1972 .p_class = P_GLOBAL,
1973 .ptr = &Globals.bLargeReadwrite,
1974 .special = NULL,
1975 .enum_list = NULL,
1976 .flags = FLAG_ADVANCED,
1979 .label = "max protocol",
1980 .type = P_ENUM,
1981 .p_class = P_GLOBAL,
1982 .ptr = &Globals.maxprotocol,
1983 .special = NULL,
1984 .enum_list = enum_protocol,
1985 .flags = FLAG_ADVANCED,
1988 .label = "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 = "min protocol",
1998 .type = P_ENUM,
1999 .p_class = P_GLOBAL,
2000 .ptr = &Globals.minprotocol,
2001 .special = NULL,
2002 .enum_list = enum_protocol,
2003 .flags = FLAG_ADVANCED,
2006 .label = "min receivefile size",
2007 .type = P_INTEGER,
2008 .p_class = P_GLOBAL,
2009 .ptr = &Globals.iminreceivefile,
2010 .special = NULL,
2011 .enum_list = NULL,
2012 .flags = FLAG_ADVANCED,
2015 .label = "read raw",
2016 .type = P_BOOL,
2017 .p_class = P_GLOBAL,
2018 .ptr = &Globals.bReadRaw,
2019 .special = NULL,
2020 .enum_list = NULL,
2021 .flags = FLAG_ADVANCED,
2024 .label = "write raw",
2025 .type = P_BOOL,
2026 .p_class = P_GLOBAL,
2027 .ptr = &Globals.bWriteRaw,
2028 .special = NULL,
2029 .enum_list = NULL,
2030 .flags = FLAG_ADVANCED,
2033 .label = "disable netbios",
2034 .type = P_BOOL,
2035 .p_class = P_GLOBAL,
2036 .ptr = &Globals.bDisableNetbios,
2037 .special = NULL,
2038 .enum_list = NULL,
2039 .flags = FLAG_ADVANCED,
2042 .label = "reset on zero vc",
2043 .type = P_BOOL,
2044 .p_class = P_GLOBAL,
2045 .ptr = &Globals.bResetOnZeroVC,
2046 .special = NULL,
2047 .enum_list = NULL,
2048 .flags = FLAG_ADVANCED,
2051 .label = "acl compatibility",
2052 .type = P_ENUM,
2053 .p_class = P_GLOBAL,
2054 .ptr = &Globals.iAclCompat,
2055 .special = NULL,
2056 .enum_list = enum_acl_compat_vals,
2057 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2060 .label = "defer sharing violations",
2061 .type = P_BOOL,
2062 .p_class = P_GLOBAL,
2063 .ptr = &Globals.bDeferSharingViolations,
2064 .special = NULL,
2065 .enum_list = NULL,
2066 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2069 .label = "ea support",
2070 .type = P_BOOL,
2071 .p_class = P_LOCAL,
2072 .ptr = &sDefault.bEASupport,
2073 .special = NULL,
2074 .enum_list = NULL,
2075 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2078 .label = "nt acl support",
2079 .type = P_BOOL,
2080 .p_class = P_LOCAL,
2081 .ptr = &sDefault.bNTAclSupport,
2082 .special = NULL,
2083 .enum_list = NULL,
2084 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2087 .label = "nt pipe support",
2088 .type = P_BOOL,
2089 .p_class = P_GLOBAL,
2090 .ptr = &Globals.bNTPipeSupport,
2091 .special = NULL,
2092 .enum_list = NULL,
2093 .flags = FLAG_ADVANCED,
2096 .label = "nt status support",
2097 .type = P_BOOL,
2098 .p_class = P_GLOBAL,
2099 .ptr = &Globals.bNTStatusSupport,
2100 .special = NULL,
2101 .enum_list = NULL,
2102 .flags = FLAG_ADVANCED,
2105 .label = "profile acls",
2106 .type = P_BOOL,
2107 .p_class = P_LOCAL,
2108 .ptr = &sDefault.bProfileAcls,
2109 .special = NULL,
2110 .enum_list = NULL,
2111 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2114 .label = "announce version",
2115 .type = P_STRING,
2116 .p_class = P_GLOBAL,
2117 .ptr = &Globals.szAnnounceVersion,
2118 .special = NULL,
2119 .enum_list = NULL,
2120 .flags = FLAG_ADVANCED,
2123 .label = "announce as",
2124 .type = P_ENUM,
2125 .p_class = P_GLOBAL,
2126 .ptr = &Globals.announce_as,
2127 .special = NULL,
2128 .enum_list = enum_announce_as,
2129 .flags = FLAG_ADVANCED,
2132 .label = "map acl inherit",
2133 .type = P_BOOL,
2134 .p_class = P_LOCAL,
2135 .ptr = &sDefault.bMap_acl_inherit,
2136 .special = NULL,
2137 .enum_list = NULL,
2138 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2141 .label = "afs share",
2142 .type = P_BOOL,
2143 .p_class = P_LOCAL,
2144 .ptr = &sDefault.bAfs_Share,
2145 .special = NULL,
2146 .enum_list = NULL,
2147 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2150 .label = "max mux",
2151 .type = P_INTEGER,
2152 .p_class = P_GLOBAL,
2153 .ptr = &Globals.max_mux,
2154 .special = NULL,
2155 .enum_list = NULL,
2156 .flags = FLAG_ADVANCED,
2159 .label = "max xmit",
2160 .type = P_INTEGER,
2161 .p_class = P_GLOBAL,
2162 .ptr = &Globals.max_xmit,
2163 .special = NULL,
2164 .enum_list = NULL,
2165 .flags = FLAG_ADVANCED,
2168 .label = "name resolve order",
2169 .type = P_STRING,
2170 .p_class = P_GLOBAL,
2171 .ptr = &Globals.szNameResolveOrder,
2172 .special = NULL,
2173 .enum_list = NULL,
2174 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2177 .label = "max ttl",
2178 .type = P_INTEGER,
2179 .p_class = P_GLOBAL,
2180 .ptr = &Globals.max_ttl,
2181 .special = NULL,
2182 .enum_list = NULL,
2183 .flags = FLAG_ADVANCED,
2186 .label = "max wins ttl",
2187 .type = P_INTEGER,
2188 .p_class = P_GLOBAL,
2189 .ptr = &Globals.max_wins_ttl,
2190 .special = NULL,
2191 .enum_list = NULL,
2192 .flags = FLAG_ADVANCED,
2195 .label = "min wins ttl",
2196 .type = P_INTEGER,
2197 .p_class = P_GLOBAL,
2198 .ptr = &Globals.min_wins_ttl,
2199 .special = NULL,
2200 .enum_list = NULL,
2201 .flags = FLAG_ADVANCED,
2204 .label = "time server",
2205 .type = P_BOOL,
2206 .p_class = P_GLOBAL,
2207 .ptr = &Globals.bTimeServer,
2208 .special = NULL,
2209 .enum_list = NULL,
2210 .flags = FLAG_ADVANCED,
2213 .label = "unix extensions",
2214 .type = P_BOOL,
2215 .p_class = P_GLOBAL,
2216 .ptr = &Globals.bUnixExtensions,
2217 .special = NULL,
2218 .enum_list = NULL,
2219 .flags = FLAG_ADVANCED,
2222 .label = "use spnego",
2223 .type = P_BOOL,
2224 .p_class = P_GLOBAL,
2225 .ptr = &Globals.bUseSpnego,
2226 .special = NULL,
2227 .enum_list = NULL,
2228 .flags = FLAG_ADVANCED,
2231 .label = "client signing",
2232 .type = P_ENUM,
2233 .p_class = P_GLOBAL,
2234 .ptr = &Globals.client_signing,
2235 .special = NULL,
2236 .enum_list = enum_smb_signing_vals,
2237 .flags = FLAG_ADVANCED,
2240 .label = "server signing",
2241 .type = P_ENUM,
2242 .p_class = P_GLOBAL,
2243 .ptr = &Globals.server_signing,
2244 .special = NULL,
2245 .enum_list = enum_smb_signing_vals,
2246 .flags = FLAG_ADVANCED,
2249 .label = "smb encrypt",
2250 .type = P_ENUM,
2251 .p_class = P_LOCAL,
2252 .ptr = &sDefault.ismb_encrypt,
2253 .special = NULL,
2254 .enum_list = enum_smb_signing_vals,
2255 .flags = FLAG_ADVANCED,
2258 .label = "client use spnego",
2259 .type = P_BOOL,
2260 .p_class = P_GLOBAL,
2261 .ptr = &Globals.bClientUseSpnego,
2262 .special = NULL,
2263 .enum_list = NULL,
2264 .flags = FLAG_ADVANCED,
2267 .label = "client ldap sasl wrapping",
2268 .type = P_ENUM,
2269 .p_class = P_GLOBAL,
2270 .ptr = &Globals.client_ldap_sasl_wrapping,
2271 .special = NULL,
2272 .enum_list = enum_ldap_sasl_wrapping,
2273 .flags = FLAG_ADVANCED,
2276 .label = "enable asu support",
2277 .type = P_BOOL,
2278 .p_class = P_GLOBAL,
2279 .ptr = &Globals.bASUSupport,
2280 .special = NULL,
2281 .enum_list = NULL,
2282 .flags = FLAG_ADVANCED,
2285 .label = "svcctl list",
2286 .type = P_LIST,
2287 .p_class = P_GLOBAL,
2288 .ptr = &Globals.szServicesList,
2289 .special = NULL,
2290 .enum_list = NULL,
2291 .flags = FLAG_ADVANCED,
2294 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2297 .label = "block size",
2298 .type = P_INTEGER,
2299 .p_class = P_LOCAL,
2300 .ptr = &sDefault.iBlock_size,
2301 .special = NULL,
2302 .enum_list = NULL,
2303 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2306 .label = "deadtime",
2307 .type = P_INTEGER,
2308 .p_class = P_GLOBAL,
2309 .ptr = &Globals.deadtime,
2310 .special = NULL,
2311 .enum_list = NULL,
2312 .flags = FLAG_ADVANCED,
2315 .label = "getwd cache",
2316 .type = P_BOOL,
2317 .p_class = P_GLOBAL,
2318 .ptr = &Globals.getwd_cache,
2319 .special = NULL,
2320 .enum_list = NULL,
2321 .flags = FLAG_ADVANCED,
2324 .label = "keepalive",
2325 .type = P_INTEGER,
2326 .p_class = P_GLOBAL,
2327 .ptr = &Globals.iKeepalive,
2328 .special = NULL,
2329 .enum_list = NULL,
2330 .flags = FLAG_ADVANCED,
2333 .label = "change notify",
2334 .type = P_BOOL,
2335 .p_class = P_LOCAL,
2336 .ptr = &sDefault.bChangeNotify,
2337 .special = NULL,
2338 .enum_list = NULL,
2339 .flags = FLAG_ADVANCED | FLAG_SHARE,
2342 .label = "directory name cache size",
2343 .type = P_INTEGER,
2344 .p_class = P_LOCAL,
2345 .ptr = &sDefault.iDirectoryNameCacheSize,
2346 .special = NULL,
2347 .enum_list = NULL,
2348 .flags = FLAG_ADVANCED | FLAG_SHARE,
2351 .label = "kernel change notify",
2352 .type = P_BOOL,
2353 .p_class = P_LOCAL,
2354 .ptr = &sDefault.bKernelChangeNotify,
2355 .special = NULL,
2356 .enum_list = NULL,
2357 .flags = FLAG_ADVANCED | FLAG_SHARE,
2360 .label = "lpq cache time",
2361 .type = P_INTEGER,
2362 .p_class = P_GLOBAL,
2363 .ptr = &Globals.lpqcachetime,
2364 .special = NULL,
2365 .enum_list = NULL,
2366 .flags = FLAG_ADVANCED,
2369 .label = "max smbd processes",
2370 .type = P_INTEGER,
2371 .p_class = P_GLOBAL,
2372 .ptr = &Globals.iMaxSmbdProcesses,
2373 .special = NULL,
2374 .enum_list = NULL,
2375 .flags = FLAG_ADVANCED,
2378 .label = "max connections",
2379 .type = P_INTEGER,
2380 .p_class = P_LOCAL,
2381 .ptr = &sDefault.iMaxConnections,
2382 .special = NULL,
2383 .enum_list = NULL,
2384 .flags = FLAG_ADVANCED | FLAG_SHARE,
2387 .label = "paranoid server security",
2388 .type = P_BOOL,
2389 .p_class = P_GLOBAL,
2390 .ptr = &Globals.paranoid_server_security,
2391 .special = NULL,
2392 .enum_list = NULL,
2393 .flags = FLAG_ADVANCED,
2396 .label = "max disk size",
2397 .type = P_INTEGER,
2398 .p_class = P_GLOBAL,
2399 .ptr = &Globals.maxdisksize,
2400 .special = NULL,
2401 .enum_list = NULL,
2402 .flags = FLAG_ADVANCED,
2405 .label = "max open files",
2406 .type = P_INTEGER,
2407 .p_class = P_GLOBAL,
2408 .ptr = &Globals.max_open_files,
2409 .special = NULL,
2410 .enum_list = NULL,
2411 .flags = FLAG_ADVANCED,
2414 .label = "min print space",
2415 .type = P_INTEGER,
2416 .p_class = P_LOCAL,
2417 .ptr = &sDefault.iMinPrintSpace,
2418 .special = NULL,
2419 .enum_list = NULL,
2420 .flags = FLAG_ADVANCED | FLAG_PRINT,
2423 .label = "socket options",
2424 .type = P_STRING,
2425 .p_class = P_GLOBAL,
2426 .ptr = &Globals.szSocketOptions,
2427 .special = NULL,
2428 .enum_list = NULL,
2429 .flags = FLAG_ADVANCED,
2432 .label = "strict allocate",
2433 .type = P_BOOL,
2434 .p_class = P_LOCAL,
2435 .ptr = &sDefault.bStrictAllocate,
2436 .special = NULL,
2437 .enum_list = NULL,
2438 .flags = FLAG_ADVANCED | FLAG_SHARE,
2441 .label = "strict sync",
2442 .type = P_BOOL,
2443 .p_class = P_LOCAL,
2444 .ptr = &sDefault.bStrictSync,
2445 .special = NULL,
2446 .enum_list = NULL,
2447 .flags = FLAG_ADVANCED | FLAG_SHARE,
2450 .label = "sync always",
2451 .type = P_BOOL,
2452 .p_class = P_LOCAL,
2453 .ptr = &sDefault.bSyncAlways,
2454 .special = NULL,
2455 .enum_list = NULL,
2456 .flags = FLAG_ADVANCED | FLAG_SHARE,
2459 .label = "use mmap",
2460 .type = P_BOOL,
2461 .p_class = P_GLOBAL,
2462 .ptr = &Globals.bUseMmap,
2463 .special = NULL,
2464 .enum_list = NULL,
2465 .flags = FLAG_ADVANCED,
2468 .label = "use sendfile",
2469 .type = P_BOOL,
2470 .p_class = P_LOCAL,
2471 .ptr = &sDefault.bUseSendfile,
2472 .special = NULL,
2473 .enum_list = NULL,
2474 .flags = FLAG_ADVANCED | FLAG_SHARE,
2477 .label = "hostname lookups",
2478 .type = P_BOOL,
2479 .p_class = P_GLOBAL,
2480 .ptr = &Globals.bHostnameLookups,
2481 .special = NULL,
2482 .enum_list = NULL,
2483 .flags = FLAG_ADVANCED,
2486 .label = "write cache size",
2487 .type = P_INTEGER,
2488 .p_class = P_LOCAL,
2489 .ptr = &sDefault.iWriteCacheSize,
2490 .special = NULL,
2491 .enum_list = NULL,
2492 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2495 .label = "name cache timeout",
2496 .type = P_INTEGER,
2497 .p_class = P_GLOBAL,
2498 .ptr = &Globals.name_cache_timeout,
2499 .special = NULL,
2500 .enum_list = NULL,
2501 .flags = FLAG_ADVANCED,
2504 .label = "ctdbd socket",
2505 .type = P_STRING,
2506 .p_class = P_GLOBAL,
2507 .ptr = &Globals.ctdbdSocket,
2508 .special = NULL,
2509 .enum_list = NULL,
2510 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2513 .label = "cluster addresses",
2514 .type = P_LIST,
2515 .p_class = P_GLOBAL,
2516 .ptr = &Globals.szClusterAddresses,
2517 .special = NULL,
2518 .enum_list = NULL,
2519 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2522 .label = "clustering",
2523 .type = P_BOOL,
2524 .p_class = P_GLOBAL,
2525 .ptr = &Globals.clustering,
2526 .special = NULL,
2527 .enum_list = NULL,
2528 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2531 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2534 .label = "max reported print jobs",
2535 .type = P_INTEGER,
2536 .p_class = P_LOCAL,
2537 .ptr = &sDefault.iMaxReportedPrintJobs,
2538 .special = NULL,
2539 .enum_list = NULL,
2540 .flags = FLAG_ADVANCED | FLAG_PRINT,
2543 .label = "max print jobs",
2544 .type = P_INTEGER,
2545 .p_class = P_LOCAL,
2546 .ptr = &sDefault.iMaxPrintJobs,
2547 .special = NULL,
2548 .enum_list = NULL,
2549 .flags = FLAG_ADVANCED | FLAG_PRINT,
2552 .label = "load printers",
2553 .type = P_BOOL,
2554 .p_class = P_GLOBAL,
2555 .ptr = &Globals.bLoadPrinters,
2556 .special = NULL,
2557 .enum_list = NULL,
2558 .flags = FLAG_ADVANCED | FLAG_PRINT,
2561 .label = "printcap cache time",
2562 .type = P_INTEGER,
2563 .p_class = P_GLOBAL,
2564 .ptr = &Globals.PrintcapCacheTime,
2565 .special = NULL,
2566 .enum_list = NULL,
2567 .flags = FLAG_ADVANCED | FLAG_PRINT,
2570 .label = "printcap name",
2571 .type = P_STRING,
2572 .p_class = P_GLOBAL,
2573 .ptr = &Globals.szPrintcapname,
2574 .special = NULL,
2575 .enum_list = NULL,
2576 .flags = FLAG_ADVANCED | FLAG_PRINT,
2579 .label = "printcap",
2580 .type = P_STRING,
2581 .p_class = P_GLOBAL,
2582 .ptr = &Globals.szPrintcapname,
2583 .special = NULL,
2584 .enum_list = NULL,
2585 .flags = FLAG_HIDE,
2588 .label = "printable",
2589 .type = P_BOOL,
2590 .p_class = P_LOCAL,
2591 .ptr = &sDefault.bPrint_ok,
2592 .special = NULL,
2593 .enum_list = NULL,
2594 .flags = FLAG_ADVANCED | FLAG_PRINT,
2597 .label = "print ok",
2598 .type = P_BOOL,
2599 .p_class = P_LOCAL,
2600 .ptr = &sDefault.bPrint_ok,
2601 .special = NULL,
2602 .enum_list = NULL,
2603 .flags = FLAG_HIDE,
2606 .label = "printing",
2607 .type = P_ENUM,
2608 .p_class = P_LOCAL,
2609 .ptr = &sDefault.iPrinting,
2610 .special = handle_printing,
2611 .enum_list = enum_printing,
2612 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2615 .label = "cups options",
2616 .type = P_STRING,
2617 .p_class = P_LOCAL,
2618 .ptr = &sDefault.szCupsOptions,
2619 .special = NULL,
2620 .enum_list = NULL,
2621 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2624 .label = "cups server",
2625 .type = P_STRING,
2626 .p_class = P_GLOBAL,
2627 .ptr = &Globals.szCupsServer,
2628 .special = NULL,
2629 .enum_list = NULL,
2630 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2633 .label = "cups connection timeout",
2634 .type = P_INTEGER,
2635 .p_class = P_GLOBAL,
2636 .ptr = &Globals.cups_connection_timeout,
2637 .special = NULL,
2638 .enum_list = NULL,
2639 .flags = FLAG_ADVANCED,
2642 .label = "iprint server",
2643 .type = P_STRING,
2644 .p_class = P_GLOBAL,
2645 .ptr = &Globals.szIPrintServer,
2646 .special = NULL,
2647 .enum_list = NULL,
2648 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2651 .label = "print command",
2652 .type = P_STRING,
2653 .p_class = P_LOCAL,
2654 .ptr = &sDefault.szPrintcommand,
2655 .special = NULL,
2656 .enum_list = NULL,
2657 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2660 .label = "disable spoolss",
2661 .type = P_BOOL,
2662 .p_class = P_GLOBAL,
2663 .ptr = &Globals.bDisableSpoolss,
2664 .special = NULL,
2665 .enum_list = NULL,
2666 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2669 .label = "enable spoolss",
2670 .type = P_BOOLREV,
2671 .p_class = P_GLOBAL,
2672 .ptr = &Globals.bDisableSpoolss,
2673 .special = NULL,
2674 .enum_list = NULL,
2675 .flags = FLAG_HIDE,
2678 .label = "lpq command",
2679 .type = P_STRING,
2680 .p_class = P_LOCAL,
2681 .ptr = &sDefault.szLpqcommand,
2682 .special = NULL,
2683 .enum_list = NULL,
2684 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2687 .label = "lprm command",
2688 .type = P_STRING,
2689 .p_class = P_LOCAL,
2690 .ptr = &sDefault.szLprmcommand,
2691 .special = NULL,
2692 .enum_list = NULL,
2693 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2696 .label = "lppause command",
2697 .type = P_STRING,
2698 .p_class = P_LOCAL,
2699 .ptr = &sDefault.szLppausecommand,
2700 .special = NULL,
2701 .enum_list = NULL,
2702 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2705 .label = "lpresume command",
2706 .type = P_STRING,
2707 .p_class = P_LOCAL,
2708 .ptr = &sDefault.szLpresumecommand,
2709 .special = NULL,
2710 .enum_list = NULL,
2711 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2714 .label = "queuepause command",
2715 .type = P_STRING,
2716 .p_class = P_LOCAL,
2717 .ptr = &sDefault.szQueuepausecommand,
2718 .special = NULL,
2719 .enum_list = NULL,
2720 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2723 .label = "queueresume command",
2724 .type = P_STRING,
2725 .p_class = P_LOCAL,
2726 .ptr = &sDefault.szQueueresumecommand,
2727 .special = NULL,
2728 .enum_list = NULL,
2729 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2732 .label = "addport command",
2733 .type = P_STRING,
2734 .p_class = P_GLOBAL,
2735 .ptr = &Globals.szAddPortCommand,
2736 .special = NULL,
2737 .enum_list = NULL,
2738 .flags = FLAG_ADVANCED,
2741 .label = "enumports command",
2742 .type = P_STRING,
2743 .p_class = P_GLOBAL,
2744 .ptr = &Globals.szEnumPortsCommand,
2745 .special = NULL,
2746 .enum_list = NULL,
2747 .flags = FLAG_ADVANCED,
2750 .label = "addprinter command",
2751 .type = P_STRING,
2752 .p_class = P_GLOBAL,
2753 .ptr = &Globals.szAddPrinterCommand,
2754 .special = NULL,
2755 .enum_list = NULL,
2756 .flags = FLAG_ADVANCED,
2759 .label = "deleteprinter command",
2760 .type = P_STRING,
2761 .p_class = P_GLOBAL,
2762 .ptr = &Globals.szDeletePrinterCommand,
2763 .special = NULL,
2764 .enum_list = NULL,
2765 .flags = FLAG_ADVANCED,
2768 .label = "show add printer wizard",
2769 .type = P_BOOL,
2770 .p_class = P_GLOBAL,
2771 .ptr = &Globals.bMsAddPrinterWizard,
2772 .special = NULL,
2773 .enum_list = NULL,
2774 .flags = FLAG_ADVANCED,
2777 .label = "os2 driver map",
2778 .type = P_STRING,
2779 .p_class = P_GLOBAL,
2780 .ptr = &Globals.szOs2DriverMap,
2781 .special = NULL,
2782 .enum_list = NULL,
2783 .flags = FLAG_ADVANCED,
2787 .label = "printer name",
2788 .type = P_STRING,
2789 .p_class = P_LOCAL,
2790 .ptr = &sDefault.szPrintername,
2791 .special = NULL,
2792 .enum_list = NULL,
2793 .flags = FLAG_ADVANCED | FLAG_PRINT,
2796 .label = "printer",
2797 .type = P_STRING,
2798 .p_class = P_LOCAL,
2799 .ptr = &sDefault.szPrintername,
2800 .special = NULL,
2801 .enum_list = NULL,
2802 .flags = FLAG_HIDE,
2805 .label = "use client driver",
2806 .type = P_BOOL,
2807 .p_class = P_LOCAL,
2808 .ptr = &sDefault.bUseClientDriver,
2809 .special = NULL,
2810 .enum_list = NULL,
2811 .flags = FLAG_ADVANCED | FLAG_PRINT,
2814 .label = "default devmode",
2815 .type = P_BOOL,
2816 .p_class = P_LOCAL,
2817 .ptr = &sDefault.bDefaultDevmode,
2818 .special = NULL,
2819 .enum_list = NULL,
2820 .flags = FLAG_ADVANCED | FLAG_PRINT,
2823 .label = "force printername",
2824 .type = P_BOOL,
2825 .p_class = P_LOCAL,
2826 .ptr = &sDefault.bForcePrintername,
2827 .special = NULL,
2828 .enum_list = NULL,
2829 .flags = FLAG_ADVANCED | FLAG_PRINT,
2832 .label = "printjob username",
2833 .type = P_STRING,
2834 .p_class = P_LOCAL,
2835 .ptr = &sDefault.szPrintjobUsername,
2836 .special = NULL,
2837 .enum_list = NULL,
2838 .flags = FLAG_ADVANCED | FLAG_PRINT,
2841 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2844 .label = "mangling method",
2845 .type = P_STRING,
2846 .p_class = P_GLOBAL,
2847 .ptr = &Globals.szManglingMethod,
2848 .special = NULL,
2849 .enum_list = NULL,
2850 .flags = FLAG_ADVANCED,
2853 .label = "mangle prefix",
2854 .type = P_INTEGER,
2855 .p_class = P_GLOBAL,
2856 .ptr = &Globals.mangle_prefix,
2857 .special = NULL,
2858 .enum_list = NULL,
2859 .flags = FLAG_ADVANCED,
2863 .label = "default case",
2864 .type = P_ENUM,
2865 .p_class = P_LOCAL,
2866 .ptr = &sDefault.iDefaultCase,
2867 .special = NULL,
2868 .enum_list = enum_case,
2869 .flags = FLAG_ADVANCED | FLAG_SHARE,
2872 .label = "case sensitive",
2873 .type = P_ENUM,
2874 .p_class = P_LOCAL,
2875 .ptr = &sDefault.iCaseSensitive,
2876 .special = NULL,
2877 .enum_list = enum_bool_auto,
2878 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2881 .label = "casesignames",
2882 .type = P_ENUM,
2883 .p_class = P_LOCAL,
2884 .ptr = &sDefault.iCaseSensitive,
2885 .special = NULL,
2886 .enum_list = enum_bool_auto,
2887 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2890 .label = "preserve case",
2891 .type = P_BOOL,
2892 .p_class = P_LOCAL,
2893 .ptr = &sDefault.bCasePreserve,
2894 .special = NULL,
2895 .enum_list = NULL,
2896 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2899 .label = "short preserve case",
2900 .type = P_BOOL,
2901 .p_class = P_LOCAL,
2902 .ptr = &sDefault.bShortCasePreserve,
2903 .special = NULL,
2904 .enum_list = NULL,
2905 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2908 .label = "mangling char",
2909 .type = P_CHAR,
2910 .p_class = P_LOCAL,
2911 .ptr = &sDefault.magic_char,
2912 .special = NULL,
2913 .enum_list = NULL,
2914 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2917 .label = "hide dot files",
2918 .type = P_BOOL,
2919 .p_class = P_LOCAL,
2920 .ptr = &sDefault.bHideDotFiles,
2921 .special = NULL,
2922 .enum_list = NULL,
2923 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2926 .label = "hide special files",
2927 .type = P_BOOL,
2928 .p_class = P_LOCAL,
2929 .ptr = &sDefault.bHideSpecialFiles,
2930 .special = NULL,
2931 .enum_list = NULL,
2932 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2935 .label = "hide unreadable",
2936 .type = P_BOOL,
2937 .p_class = P_LOCAL,
2938 .ptr = &sDefault.bHideUnReadable,
2939 .special = NULL,
2940 .enum_list = NULL,
2941 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2944 .label = "hide unwriteable files",
2945 .type = P_BOOL,
2946 .p_class = P_LOCAL,
2947 .ptr = &sDefault.bHideUnWriteableFiles,
2948 .special = NULL,
2949 .enum_list = NULL,
2950 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2953 .label = "delete veto files",
2954 .type = P_BOOL,
2955 .p_class = P_LOCAL,
2956 .ptr = &sDefault.bDeleteVetoFiles,
2957 .special = NULL,
2958 .enum_list = NULL,
2959 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2962 .label = "veto files",
2963 .type = P_STRING,
2964 .p_class = P_LOCAL,
2965 .ptr = &sDefault.szVetoFiles,
2966 .special = NULL,
2967 .enum_list = NULL,
2968 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2971 .label = "hide files",
2972 .type = P_STRING,
2973 .p_class = P_LOCAL,
2974 .ptr = &sDefault.szHideFiles,
2975 .special = NULL,
2976 .enum_list = NULL,
2977 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2980 .label = "veto oplock files",
2981 .type = P_STRING,
2982 .p_class = P_LOCAL,
2983 .ptr = &sDefault.szVetoOplockFiles,
2984 .special = NULL,
2985 .enum_list = NULL,
2986 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2989 .label = "map archive",
2990 .type = P_BOOL,
2991 .p_class = P_LOCAL,
2992 .ptr = &sDefault.bMap_archive,
2993 .special = NULL,
2994 .enum_list = NULL,
2995 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2998 .label = "map hidden",
2999 .type = P_BOOL,
3000 .p_class = P_LOCAL,
3001 .ptr = &sDefault.bMap_hidden,
3002 .special = NULL,
3003 .enum_list = NULL,
3004 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3007 .label = "map system",
3008 .type = P_BOOL,
3009 .p_class = P_LOCAL,
3010 .ptr = &sDefault.bMap_system,
3011 .special = NULL,
3012 .enum_list = NULL,
3013 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3016 .label = "map readonly",
3017 .type = P_ENUM,
3018 .p_class = P_LOCAL,
3019 .ptr = &sDefault.iMap_readonly,
3020 .special = NULL,
3021 .enum_list = enum_map_readonly,
3022 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3025 .label = "mangled names",
3026 .type = P_BOOL,
3027 .p_class = P_LOCAL,
3028 .ptr = &sDefault.bMangledNames,
3029 .special = NULL,
3030 .enum_list = NULL,
3031 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3034 .label = "max stat cache size",
3035 .type = P_INTEGER,
3036 .p_class = P_GLOBAL,
3037 .ptr = &Globals.iMaxStatCacheSize,
3038 .special = NULL,
3039 .enum_list = NULL,
3040 .flags = FLAG_ADVANCED,
3043 .label = "stat cache",
3044 .type = P_BOOL,
3045 .p_class = P_GLOBAL,
3046 .ptr = &Globals.bStatCache,
3047 .special = NULL,
3048 .enum_list = NULL,
3049 .flags = FLAG_ADVANCED,
3052 .label = "store dos attributes",
3053 .type = P_BOOL,
3054 .p_class = P_LOCAL,
3055 .ptr = &sDefault.bStoreDosAttributes,
3056 .special = NULL,
3057 .enum_list = NULL,
3058 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3061 .label = "dmapi support",
3062 .type = P_BOOL,
3063 .p_class = P_LOCAL,
3064 .ptr = &sDefault.bDmapiSupport,
3065 .special = NULL,
3066 .enum_list = NULL,
3067 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3071 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3074 .label = "machine password timeout",
3075 .type = P_INTEGER,
3076 .p_class = P_GLOBAL,
3077 .ptr = &Globals.machine_password_timeout,
3078 .special = NULL,
3079 .enum_list = NULL,
3080 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3083 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3086 .label = "add user script",
3087 .type = P_STRING,
3088 .p_class = P_GLOBAL,
3089 .ptr = &Globals.szAddUserScript,
3090 .special = NULL,
3091 .enum_list = NULL,
3092 .flags = FLAG_ADVANCED,
3095 .label = "rename user script",
3096 .type = P_STRING,
3097 .p_class = P_GLOBAL,
3098 .ptr = &Globals.szRenameUserScript,
3099 .special = NULL,
3100 .enum_list = NULL,
3101 .flags = FLAG_ADVANCED,
3104 .label = "delete user script",
3105 .type = P_STRING,
3106 .p_class = P_GLOBAL,
3107 .ptr = &Globals.szDelUserScript,
3108 .special = NULL,
3109 .enum_list = NULL,
3110 .flags = FLAG_ADVANCED,
3113 .label = "add group script",
3114 .type = P_STRING,
3115 .p_class = P_GLOBAL,
3116 .ptr = &Globals.szAddGroupScript,
3117 .special = NULL,
3118 .enum_list = NULL,
3119 .flags = FLAG_ADVANCED,
3122 .label = "delete group script",
3123 .type = P_STRING,
3124 .p_class = P_GLOBAL,
3125 .ptr = &Globals.szDelGroupScript,
3126 .special = NULL,
3127 .enum_list = NULL,
3128 .flags = FLAG_ADVANCED,
3131 .label = "add user to group script",
3132 .type = P_STRING,
3133 .p_class = P_GLOBAL,
3134 .ptr = &Globals.szAddUserToGroupScript,
3135 .special = NULL,
3136 .enum_list = NULL,
3137 .flags = FLAG_ADVANCED,
3140 .label = "delete user from group script",
3141 .type = P_STRING,
3142 .p_class = P_GLOBAL,
3143 .ptr = &Globals.szDelUserFromGroupScript,
3144 .special = NULL,
3145 .enum_list = NULL,
3146 .flags = FLAG_ADVANCED,
3149 .label = "set primary group script",
3150 .type = P_STRING,
3151 .p_class = P_GLOBAL,
3152 .ptr = &Globals.szSetPrimaryGroupScript,
3153 .special = NULL,
3154 .enum_list = NULL,
3155 .flags = FLAG_ADVANCED,
3158 .label = "add machine script",
3159 .type = P_STRING,
3160 .p_class = P_GLOBAL,
3161 .ptr = &Globals.szAddMachineScript,
3162 .special = NULL,
3163 .enum_list = NULL,
3164 .flags = FLAG_ADVANCED,
3167 .label = "shutdown script",
3168 .type = P_STRING,
3169 .p_class = P_GLOBAL,
3170 .ptr = &Globals.szShutdownScript,
3171 .special = NULL,
3172 .enum_list = NULL,
3173 .flags = FLAG_ADVANCED,
3176 .label = "abort shutdown script",
3177 .type = P_STRING,
3178 .p_class = P_GLOBAL,
3179 .ptr = &Globals.szAbortShutdownScript,
3180 .special = NULL,
3181 .enum_list = NULL,
3182 .flags = FLAG_ADVANCED,
3185 .label = "username map script",
3186 .type = P_STRING,
3187 .p_class = P_GLOBAL,
3188 .ptr = &Globals.szUsernameMapScript,
3189 .special = NULL,
3190 .enum_list = NULL,
3191 .flags = FLAG_ADVANCED,
3194 .label = "logon script",
3195 .type = P_STRING,
3196 .p_class = P_GLOBAL,
3197 .ptr = &Globals.szLogonScript,
3198 .special = NULL,
3199 .enum_list = NULL,
3200 .flags = FLAG_ADVANCED,
3203 .label = "logon path",
3204 .type = P_STRING,
3205 .p_class = P_GLOBAL,
3206 .ptr = &Globals.szLogonPath,
3207 .special = NULL,
3208 .enum_list = NULL,
3209 .flags = FLAG_ADVANCED,
3212 .label = "logon drive",
3213 .type = P_STRING,
3214 .p_class = P_GLOBAL,
3215 .ptr = &Globals.szLogonDrive,
3216 .special = NULL,
3217 .enum_list = NULL,
3218 .flags = FLAG_ADVANCED,
3221 .label = "logon home",
3222 .type = P_STRING,
3223 .p_class = P_GLOBAL,
3224 .ptr = &Globals.szLogonHome,
3225 .special = NULL,
3226 .enum_list = NULL,
3227 .flags = FLAG_ADVANCED,
3230 .label = "domain logons",
3231 .type = P_BOOL,
3232 .p_class = P_GLOBAL,
3233 .ptr = &Globals.bDomainLogons,
3234 .special = NULL,
3235 .enum_list = NULL,
3236 .flags = FLAG_ADVANCED,
3240 .label = "init logon delayed hosts",
3241 .type = P_LIST,
3242 .p_class = P_GLOBAL,
3243 .ptr = &Globals.szInitLogonDelayedHosts,
3244 .flags = FLAG_ADVANCED,
3248 .label = "init logon delay",
3249 .type = P_INTEGER,
3250 .p_class = P_GLOBAL,
3251 .ptr = &Globals.InitLogonDelay,
3252 .flags = FLAG_ADVANCED,
3256 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3259 .label = "os level",
3260 .type = P_INTEGER,
3261 .p_class = P_GLOBAL,
3262 .ptr = &Globals.os_level,
3263 .special = NULL,
3264 .enum_list = NULL,
3265 .flags = FLAG_BASIC | FLAG_ADVANCED,
3268 .label = "lm announce",
3269 .type = P_ENUM,
3270 .p_class = P_GLOBAL,
3271 .ptr = &Globals.lm_announce,
3272 .special = NULL,
3273 .enum_list = enum_bool_auto,
3274 .flags = FLAG_ADVANCED,
3277 .label = "lm interval",
3278 .type = P_INTEGER,
3279 .p_class = P_GLOBAL,
3280 .ptr = &Globals.lm_interval,
3281 .special = NULL,
3282 .enum_list = NULL,
3283 .flags = FLAG_ADVANCED,
3286 .label = "preferred master",
3287 .type = P_ENUM,
3288 .p_class = P_GLOBAL,
3289 .ptr = &Globals.iPreferredMaster,
3290 .special = NULL,
3291 .enum_list = enum_bool_auto,
3292 .flags = FLAG_BASIC | FLAG_ADVANCED,
3295 .label = "prefered master",
3296 .type = P_ENUM,
3297 .p_class = P_GLOBAL,
3298 .ptr = &Globals.iPreferredMaster,
3299 .special = NULL,
3300 .enum_list = enum_bool_auto,
3301 .flags = FLAG_HIDE,
3304 .label = "local master",
3305 .type = P_BOOL,
3306 .p_class = P_GLOBAL,
3307 .ptr = &Globals.bLocalMaster,
3308 .special = NULL,
3309 .enum_list = NULL,
3310 .flags = FLAG_BASIC | FLAG_ADVANCED,
3313 .label = "domain master",
3314 .type = P_ENUM,
3315 .p_class = P_GLOBAL,
3316 .ptr = &Globals.iDomainMaster,
3317 .special = NULL,
3318 .enum_list = enum_bool_auto,
3319 .flags = FLAG_BASIC | FLAG_ADVANCED,
3322 .label = "browse list",
3323 .type = P_BOOL,
3324 .p_class = P_GLOBAL,
3325 .ptr = &Globals.bBrowseList,
3326 .special = NULL,
3327 .enum_list = NULL,
3328 .flags = FLAG_ADVANCED,
3331 .label = "browseable",
3332 .type = P_BOOL,
3333 .p_class = P_LOCAL,
3334 .ptr = &sDefault.bBrowseable,
3335 .special = NULL,
3336 .enum_list = NULL,
3337 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3340 .label = "access based share enum",
3341 .type = P_BOOL,
3342 .p_class = P_LOCAL,
3343 .ptr = &sDefault.bAccessBasedShareEnum,
3344 .special = NULL,
3345 .enum_list = NULL,
3346 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE
3349 .label = "browsable",
3350 .type = P_BOOL,
3351 .p_class = P_LOCAL,
3352 .ptr = &sDefault.bBrowseable,
3353 .special = NULL,
3354 .enum_list = NULL,
3355 .flags = FLAG_HIDE,
3358 .label = "enhanced browsing",
3359 .type = P_BOOL,
3360 .p_class = P_GLOBAL,
3361 .ptr = &Globals.enhanced_browsing,
3362 .special = NULL,
3363 .enum_list = NULL,
3364 .flags = FLAG_ADVANCED,
3367 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3370 .label = "dns proxy",
3371 .type = P_BOOL,
3372 .p_class = P_GLOBAL,
3373 .ptr = &Globals.bDNSproxy,
3374 .special = NULL,
3375 .enum_list = NULL,
3376 .flags = FLAG_ADVANCED,
3379 .label = "wins proxy",
3380 .type = P_BOOL,
3381 .p_class = P_GLOBAL,
3382 .ptr = &Globals.bWINSproxy,
3383 .special = NULL,
3384 .enum_list = NULL,
3385 .flags = FLAG_ADVANCED,
3388 .label = "wins server",
3389 .type = P_LIST,
3390 .p_class = P_GLOBAL,
3391 .ptr = &Globals.szWINSservers,
3392 .special = NULL,
3393 .enum_list = NULL,
3394 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3397 .label = "wins support",
3398 .type = P_BOOL,
3399 .p_class = P_GLOBAL,
3400 .ptr = &Globals.bWINSsupport,
3401 .special = NULL,
3402 .enum_list = NULL,
3403 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3406 .label = "wins hook",
3407 .type = P_STRING,
3408 .p_class = P_GLOBAL,
3409 .ptr = &Globals.szWINSHook,
3410 .special = NULL,
3411 .enum_list = NULL,
3412 .flags = FLAG_ADVANCED,
3415 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3418 .label = "blocking locks",
3419 .type = P_BOOL,
3420 .p_class = P_LOCAL,
3421 .ptr = &sDefault.bBlockingLocks,
3422 .special = NULL,
3423 .enum_list = NULL,
3424 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3427 .label = "csc policy",
3428 .type = P_ENUM,
3429 .p_class = P_LOCAL,
3430 .ptr = &sDefault.iCSCPolicy,
3431 .special = NULL,
3432 .enum_list = enum_csc_policy,
3433 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3436 .label = "fake oplocks",
3437 .type = P_BOOL,
3438 .p_class = P_LOCAL,
3439 .ptr = &sDefault.bFakeOplocks,
3440 .special = NULL,
3441 .enum_list = NULL,
3442 .flags = FLAG_ADVANCED | FLAG_SHARE,
3445 .label = "kernel oplocks",
3446 .type = P_BOOL,
3447 .p_class = P_GLOBAL,
3448 .ptr = &Globals.bKernelOplocks,
3449 .special = NULL,
3450 .enum_list = NULL,
3451 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3454 .label = "locking",
3455 .type = P_BOOL,
3456 .p_class = P_LOCAL,
3457 .ptr = &sDefault.bLocking,
3458 .special = NULL,
3459 .enum_list = NULL,
3460 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3463 .label = "lock spin time",
3464 .type = P_INTEGER,
3465 .p_class = P_GLOBAL,
3466 .ptr = &Globals.iLockSpinTime,
3467 .special = NULL,
3468 .enum_list = NULL,
3469 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3472 .label = "oplocks",
3473 .type = P_BOOL,
3474 .p_class = P_LOCAL,
3475 .ptr = &sDefault.bOpLocks,
3476 .special = NULL,
3477 .enum_list = NULL,
3478 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3481 .label = "level2 oplocks",
3482 .type = P_BOOL,
3483 .p_class = P_LOCAL,
3484 .ptr = &sDefault.bLevel2OpLocks,
3485 .special = NULL,
3486 .enum_list = NULL,
3487 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3490 .label = "oplock break wait time",
3491 .type = P_INTEGER,
3492 .p_class = P_GLOBAL,
3493 .ptr = &Globals.oplock_break_wait_time,
3494 .special = NULL,
3495 .enum_list = NULL,
3496 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3499 .label = "oplock contention limit",
3500 .type = P_INTEGER,
3501 .p_class = P_LOCAL,
3502 .ptr = &sDefault.iOplockContentionLimit,
3503 .special = NULL,
3504 .enum_list = NULL,
3505 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3508 .label = "posix locking",
3509 .type = P_BOOL,
3510 .p_class = P_LOCAL,
3511 .ptr = &sDefault.bPosixLocking,
3512 .special = NULL,
3513 .enum_list = NULL,
3514 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3517 .label = "strict locking",
3518 .type = P_ENUM,
3519 .p_class = P_LOCAL,
3520 .ptr = &sDefault.iStrictLocking,
3521 .special = NULL,
3522 .enum_list = enum_bool_auto,
3523 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3526 .label = "share modes",
3527 .type = P_BOOL,
3528 .p_class = P_LOCAL,
3529 .ptr = &sDefault.bShareModes,
3530 .special = NULL,
3531 .enum_list = NULL,
3532 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3535 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3538 .label = "ldap admin dn",
3539 .type = P_STRING,
3540 .p_class = P_GLOBAL,
3541 .ptr = &Globals.szLdapAdminDn,
3542 .special = NULL,
3543 .enum_list = NULL,
3544 .flags = FLAG_ADVANCED,
3547 .label = "ldap delete dn",
3548 .type = P_BOOL,
3549 .p_class = P_GLOBAL,
3550 .ptr = &Globals.ldap_delete_dn,
3551 .special = NULL,
3552 .enum_list = NULL,
3553 .flags = FLAG_ADVANCED,
3556 .label = "ldap group suffix",
3557 .type = P_STRING,
3558 .p_class = P_GLOBAL,
3559 .ptr = &Globals.szLdapGroupSuffix,
3560 .special = NULL,
3561 .enum_list = NULL,
3562 .flags = FLAG_ADVANCED,
3565 .label = "ldap idmap suffix",
3566 .type = P_STRING,
3567 .p_class = P_GLOBAL,
3568 .ptr = &Globals.szLdapIdmapSuffix,
3569 .special = NULL,
3570 .enum_list = NULL,
3571 .flags = FLAG_ADVANCED,
3574 .label = "ldap machine suffix",
3575 .type = P_STRING,
3576 .p_class = P_GLOBAL,
3577 .ptr = &Globals.szLdapMachineSuffix,
3578 .special = NULL,
3579 .enum_list = NULL,
3580 .flags = FLAG_ADVANCED,
3583 .label = "ldap passwd sync",
3584 .type = P_ENUM,
3585 .p_class = P_GLOBAL,
3586 .ptr = &Globals.ldap_passwd_sync,
3587 .special = NULL,
3588 .enum_list = enum_ldap_passwd_sync,
3589 .flags = FLAG_ADVANCED,
3592 .label = "ldap password sync",
3593 .type = P_ENUM,
3594 .p_class = P_GLOBAL,
3595 .ptr = &Globals.ldap_passwd_sync,
3596 .special = NULL,
3597 .enum_list = enum_ldap_passwd_sync,
3598 .flags = FLAG_HIDE,
3601 .label = "ldap replication sleep",
3602 .type = P_INTEGER,
3603 .p_class = P_GLOBAL,
3604 .ptr = &Globals.ldap_replication_sleep,
3605 .special = NULL,
3606 .enum_list = NULL,
3607 .flags = FLAG_ADVANCED,
3610 .label = "ldap suffix",
3611 .type = P_STRING,
3612 .p_class = P_GLOBAL,
3613 .ptr = &Globals.szLdapSuffix,
3614 .special = NULL,
3615 .enum_list = NULL,
3616 .flags = FLAG_ADVANCED,
3619 .label = "ldap ssl",
3620 .type = P_ENUM,
3621 .p_class = P_GLOBAL,
3622 .ptr = &Globals.ldap_ssl,
3623 .special = NULL,
3624 .enum_list = enum_ldap_ssl,
3625 .flags = FLAG_ADVANCED,
3628 .label = "ldap ssl ads",
3629 .type = P_BOOL,
3630 .p_class = P_GLOBAL,
3631 .ptr = &Globals.ldap_ssl_ads,
3632 .special = NULL,
3633 .enum_list = NULL,
3634 .flags = FLAG_ADVANCED,
3637 .label = "ldap timeout",
3638 .type = P_INTEGER,
3639 .p_class = P_GLOBAL,
3640 .ptr = &Globals.ldap_timeout,
3641 .special = NULL,
3642 .enum_list = NULL,
3643 .flags = FLAG_ADVANCED,
3646 .label = "ldap connection timeout",
3647 .type = P_INTEGER,
3648 .p_class = P_GLOBAL,
3649 .ptr = &Globals.ldap_connection_timeout,
3650 .special = NULL,
3651 .enum_list = NULL,
3652 .flags = FLAG_ADVANCED,
3655 .label = "ldap page size",
3656 .type = P_INTEGER,
3657 .p_class = P_GLOBAL,
3658 .ptr = &Globals.ldap_page_size,
3659 .special = NULL,
3660 .enum_list = NULL,
3661 .flags = FLAG_ADVANCED,
3664 .label = "ldap user suffix",
3665 .type = P_STRING,
3666 .p_class = P_GLOBAL,
3667 .ptr = &Globals.szLdapUserSuffix,
3668 .special = NULL,
3669 .enum_list = NULL,
3670 .flags = FLAG_ADVANCED,
3673 .label = "ldap debug level",
3674 .type = P_INTEGER,
3675 .p_class = P_GLOBAL,
3676 .ptr = &Globals.ldap_debug_level,
3677 .special = handle_ldap_debug_level,
3678 .enum_list = NULL,
3679 .flags = FLAG_ADVANCED,
3682 .label = "ldap debug threshold",
3683 .type = P_INTEGER,
3684 .p_class = P_GLOBAL,
3685 .ptr = &Globals.ldap_debug_threshold,
3686 .special = NULL,
3687 .enum_list = NULL,
3688 .flags = FLAG_ADVANCED,
3691 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3694 .label = "eventlog list",
3695 .type = P_LIST,
3696 .p_class = P_GLOBAL,
3697 .ptr = &Globals.szEventLogs,
3698 .special = NULL,
3699 .enum_list = NULL,
3700 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3703 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3706 .label = "add share command",
3707 .type = P_STRING,
3708 .p_class = P_GLOBAL,
3709 .ptr = &Globals.szAddShareCommand,
3710 .special = NULL,
3711 .enum_list = NULL,
3712 .flags = FLAG_ADVANCED,
3715 .label = "change share command",
3716 .type = P_STRING,
3717 .p_class = P_GLOBAL,
3718 .ptr = &Globals.szChangeShareCommand,
3719 .special = NULL,
3720 .enum_list = NULL,
3721 .flags = FLAG_ADVANCED,
3724 .label = "delete share command",
3725 .type = P_STRING,
3726 .p_class = P_GLOBAL,
3727 .ptr = &Globals.szDeleteShareCommand,
3728 .special = NULL,
3729 .enum_list = NULL,
3730 .flags = FLAG_ADVANCED,
3733 .label = "config file",
3734 .type = P_STRING,
3735 .p_class = P_GLOBAL,
3736 .ptr = &Globals.szConfigFile,
3737 .special = NULL,
3738 .enum_list = NULL,
3739 .flags = FLAG_HIDE,
3742 .label = "preload",
3743 .type = P_STRING,
3744 .p_class = P_GLOBAL,
3745 .ptr = &Globals.szAutoServices,
3746 .special = NULL,
3747 .enum_list = NULL,
3748 .flags = FLAG_ADVANCED,
3751 .label = "auto services",
3752 .type = P_STRING,
3753 .p_class = P_GLOBAL,
3754 .ptr = &Globals.szAutoServices,
3755 .special = NULL,
3756 .enum_list = NULL,
3757 .flags = FLAG_ADVANCED,
3760 .label = "lock directory",
3761 .type = P_STRING,
3762 .p_class = P_GLOBAL,
3763 .ptr = &Globals.szLockDir,
3764 .special = NULL,
3765 .enum_list = NULL,
3766 .flags = FLAG_ADVANCED,
3769 .label = "lock dir",
3770 .type = P_STRING,
3771 .p_class = P_GLOBAL,
3772 .ptr = &Globals.szLockDir,
3773 .special = NULL,
3774 .enum_list = NULL,
3775 .flags = FLAG_HIDE,
3778 .label = "state directory",
3779 .type = P_STRING,
3780 .p_class = P_GLOBAL,
3781 .ptr = &Globals.szStateDir,
3782 .special = NULL,
3783 .enum_list = NULL,
3784 .flags = FLAG_ADVANCED,
3787 .label = "cache directory",
3788 .type = P_STRING,
3789 .p_class = P_GLOBAL,
3790 .ptr = &Globals.szCacheDir,
3791 .special = NULL,
3792 .enum_list = NULL,
3793 .flags = FLAG_ADVANCED,
3796 .label = "pid directory",
3797 .type = P_STRING,
3798 .p_class = P_GLOBAL,
3799 .ptr = &Globals.szPidDir,
3800 .special = NULL,
3801 .enum_list = NULL,
3802 .flags = FLAG_ADVANCED,
3804 #ifdef WITH_UTMP
3806 .label = "utmp directory",
3807 .type = P_STRING,
3808 .p_class = P_GLOBAL,
3809 .ptr = &Globals.szUtmpDir,
3810 .special = NULL,
3811 .enum_list = NULL,
3812 .flags = FLAG_ADVANCED,
3815 .label = "wtmp directory",
3816 .type = P_STRING,
3817 .p_class = P_GLOBAL,
3818 .ptr = &Globals.szWtmpDir,
3819 .special = NULL,
3820 .enum_list = NULL,
3821 .flags = FLAG_ADVANCED,
3824 .label = "utmp",
3825 .type = P_BOOL,
3826 .p_class = P_GLOBAL,
3827 .ptr = &Globals.bUtmp,
3828 .special = NULL,
3829 .enum_list = NULL,
3830 .flags = FLAG_ADVANCED,
3832 #endif
3834 .label = "default service",
3835 .type = P_STRING,
3836 .p_class = P_GLOBAL,
3837 .ptr = &Globals.szDefaultService,
3838 .special = NULL,
3839 .enum_list = NULL,
3840 .flags = FLAG_ADVANCED,
3843 .label = "default",
3844 .type = P_STRING,
3845 .p_class = P_GLOBAL,
3846 .ptr = &Globals.szDefaultService,
3847 .special = NULL,
3848 .enum_list = NULL,
3849 .flags = FLAG_ADVANCED,
3852 .label = "message command",
3853 .type = P_STRING,
3854 .p_class = P_GLOBAL,
3855 .ptr = &Globals.szMsgCommand,
3856 .special = NULL,
3857 .enum_list = NULL,
3858 .flags = FLAG_ADVANCED,
3861 .label = "dfree cache time",
3862 .type = P_INTEGER,
3863 .p_class = P_LOCAL,
3864 .ptr = &sDefault.iDfreeCacheTime,
3865 .special = NULL,
3866 .enum_list = NULL,
3867 .flags = FLAG_ADVANCED,
3870 .label = "dfree command",
3871 .type = P_STRING,
3872 .p_class = P_LOCAL,
3873 .ptr = &sDefault.szDfree,
3874 .special = NULL,
3875 .enum_list = NULL,
3876 .flags = FLAG_ADVANCED,
3879 .label = "get quota command",
3880 .type = P_STRING,
3881 .p_class = P_GLOBAL,
3882 .ptr = &Globals.szGetQuota,
3883 .special = NULL,
3884 .enum_list = NULL,
3885 .flags = FLAG_ADVANCED,
3888 .label = "set quota command",
3889 .type = P_STRING,
3890 .p_class = P_GLOBAL,
3891 .ptr = &Globals.szSetQuota,
3892 .special = NULL,
3893 .enum_list = NULL,
3894 .flags = FLAG_ADVANCED,
3897 .label = "remote announce",
3898 .type = P_STRING,
3899 .p_class = P_GLOBAL,
3900 .ptr = &Globals.szRemoteAnnounce,
3901 .special = NULL,
3902 .enum_list = NULL,
3903 .flags = FLAG_ADVANCED,
3906 .label = "remote browse sync",
3907 .type = P_STRING,
3908 .p_class = P_GLOBAL,
3909 .ptr = &Globals.szRemoteBrowseSync,
3910 .special = NULL,
3911 .enum_list = NULL,
3912 .flags = FLAG_ADVANCED,
3915 .label = "socket address",
3916 .type = P_STRING,
3917 .p_class = P_GLOBAL,
3918 .ptr = &Globals.szSocketAddress,
3919 .special = NULL,
3920 .enum_list = NULL,
3921 .flags = FLAG_ADVANCED,
3924 .label = "homedir map",
3925 .type = P_STRING,
3926 .p_class = P_GLOBAL,
3927 .ptr = &Globals.szNISHomeMapName,
3928 .special = NULL,
3929 .enum_list = NULL,
3930 .flags = FLAG_ADVANCED,
3933 .label = "afs username map",
3934 .type = P_STRING,
3935 .p_class = P_GLOBAL,
3936 .ptr = &Globals.szAfsUsernameMap,
3937 .special = NULL,
3938 .enum_list = NULL,
3939 .flags = FLAG_ADVANCED,
3942 .label = "afs token lifetime",
3943 .type = P_INTEGER,
3944 .p_class = P_GLOBAL,
3945 .ptr = &Globals.iAfsTokenLifetime,
3946 .special = NULL,
3947 .enum_list = NULL,
3948 .flags = FLAG_ADVANCED,
3951 .label = "log nt token command",
3952 .type = P_STRING,
3953 .p_class = P_GLOBAL,
3954 .ptr = &Globals.szLogNtTokenCommand,
3955 .special = NULL,
3956 .enum_list = NULL,
3957 .flags = FLAG_ADVANCED,
3960 .label = "time offset",
3961 .type = P_INTEGER,
3962 .p_class = P_GLOBAL,
3963 .ptr = &extra_time_offset,
3964 .special = NULL,
3965 .enum_list = NULL,
3966 .flags = FLAG_ADVANCED,
3969 .label = "NIS homedir",
3970 .type = P_BOOL,
3971 .p_class = P_GLOBAL,
3972 .ptr = &Globals.bNISHomeMap,
3973 .special = NULL,
3974 .enum_list = NULL,
3975 .flags = FLAG_ADVANCED,
3978 .label = "-valid",
3979 .type = P_BOOL,
3980 .p_class = P_LOCAL,
3981 .ptr = &sDefault.valid,
3982 .special = NULL,
3983 .enum_list = NULL,
3984 .flags = FLAG_HIDE,
3987 .label = "copy",
3988 .type = P_STRING,
3989 .p_class = P_LOCAL,
3990 .ptr = &sDefault.szCopy,
3991 .special = handle_copy,
3992 .enum_list = NULL,
3993 .flags = FLAG_HIDE,
3996 .label = "include",
3997 .type = P_STRING,
3998 .p_class = P_LOCAL,
3999 .ptr = &sDefault.szInclude,
4000 .special = handle_include,
4001 .enum_list = NULL,
4002 .flags = FLAG_HIDE,
4005 .label = "preexec",
4006 .type = P_STRING,
4007 .p_class = P_LOCAL,
4008 .ptr = &sDefault.szPreExec,
4009 .special = NULL,
4010 .enum_list = NULL,
4011 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4014 .label = "exec",
4015 .type = P_STRING,
4016 .p_class = P_LOCAL,
4017 .ptr = &sDefault.szPreExec,
4018 .special = NULL,
4019 .enum_list = NULL,
4020 .flags = FLAG_ADVANCED,
4023 .label = "preexec close",
4024 .type = P_BOOL,
4025 .p_class = P_LOCAL,
4026 .ptr = &sDefault.bPreexecClose,
4027 .special = NULL,
4028 .enum_list = NULL,
4029 .flags = FLAG_ADVANCED | FLAG_SHARE,
4032 .label = "postexec",
4033 .type = P_STRING,
4034 .p_class = P_LOCAL,
4035 .ptr = &sDefault.szPostExec,
4036 .special = NULL,
4037 .enum_list = NULL,
4038 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4041 .label = "root preexec",
4042 .type = P_STRING,
4043 .p_class = P_LOCAL,
4044 .ptr = &sDefault.szRootPreExec,
4045 .special = NULL,
4046 .enum_list = NULL,
4047 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4050 .label = "root preexec close",
4051 .type = P_BOOL,
4052 .p_class = P_LOCAL,
4053 .ptr = &sDefault.bRootpreexecClose,
4054 .special = NULL,
4055 .enum_list = NULL,
4056 .flags = FLAG_ADVANCED | FLAG_SHARE,
4059 .label = "root postexec",
4060 .type = P_STRING,
4061 .p_class = P_LOCAL,
4062 .ptr = &sDefault.szRootPostExec,
4063 .special = NULL,
4064 .enum_list = NULL,
4065 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4068 .label = "available",
4069 .type = P_BOOL,
4070 .p_class = P_LOCAL,
4071 .ptr = &sDefault.bAvailable,
4072 .special = NULL,
4073 .enum_list = NULL,
4074 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4077 .label = "registry shares",
4078 .type = P_BOOL,
4079 .p_class = P_GLOBAL,
4080 .ptr = &Globals.bRegistryShares,
4081 .special = NULL,
4082 .enum_list = NULL,
4083 .flags = FLAG_ADVANCED,
4086 .label = "usershare allow guests",
4087 .type = P_BOOL,
4088 .p_class = P_GLOBAL,
4089 .ptr = &Globals.bUsershareAllowGuests,
4090 .special = NULL,
4091 .enum_list = NULL,
4092 .flags = FLAG_ADVANCED,
4095 .label = "usershare max shares",
4096 .type = P_INTEGER,
4097 .p_class = P_GLOBAL,
4098 .ptr = &Globals.iUsershareMaxShares,
4099 .special = NULL,
4100 .enum_list = NULL,
4101 .flags = FLAG_ADVANCED,
4104 .label = "usershare owner only",
4105 .type = P_BOOL,
4106 .p_class = P_GLOBAL,
4107 .ptr = &Globals.bUsershareOwnerOnly,
4108 .special = NULL,
4109 .enum_list = NULL,
4110 .flags = FLAG_ADVANCED,
4113 .label = "usershare path",
4114 .type = P_STRING,
4115 .p_class = P_GLOBAL,
4116 .ptr = &Globals.szUsersharePath,
4117 .special = NULL,
4118 .enum_list = NULL,
4119 .flags = FLAG_ADVANCED,
4122 .label = "usershare prefix allow list",
4123 .type = P_LIST,
4124 .p_class = P_GLOBAL,
4125 .ptr = &Globals.szUsersharePrefixAllowList,
4126 .special = NULL,
4127 .enum_list = NULL,
4128 .flags = FLAG_ADVANCED,
4131 .label = "usershare prefix deny list",
4132 .type = P_LIST,
4133 .p_class = P_GLOBAL,
4134 .ptr = &Globals.szUsersharePrefixDenyList,
4135 .special = NULL,
4136 .enum_list = NULL,
4137 .flags = FLAG_ADVANCED,
4140 .label = "usershare template share",
4141 .type = P_STRING,
4142 .p_class = P_GLOBAL,
4143 .ptr = &Globals.szUsershareTemplateShare,
4144 .special = NULL,
4145 .enum_list = NULL,
4146 .flags = FLAG_ADVANCED,
4149 .label = "volume",
4150 .type = P_STRING,
4151 .p_class = P_LOCAL,
4152 .ptr = &sDefault.volume,
4153 .special = NULL,
4154 .enum_list = NULL,
4155 .flags = FLAG_ADVANCED | FLAG_SHARE,
4158 .label = "fstype",
4159 .type = P_STRING,
4160 .p_class = P_LOCAL,
4161 .ptr = &sDefault.fstype,
4162 .special = NULL,
4163 .enum_list = NULL,
4164 .flags = FLAG_ADVANCED | FLAG_SHARE,
4167 .label = "set directory",
4168 .type = P_BOOLREV,
4169 .p_class = P_LOCAL,
4170 .ptr = &sDefault.bNo_set_dir,
4171 .special = NULL,
4172 .enum_list = NULL,
4173 .flags = FLAG_ADVANCED | FLAG_SHARE,
4176 .label = "wide links",
4177 .type = P_BOOL,
4178 .p_class = P_LOCAL,
4179 .ptr = &sDefault.bWidelinks,
4180 .special = NULL,
4181 .enum_list = NULL,
4182 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4185 .label = "follow symlinks",
4186 .type = P_BOOL,
4187 .p_class = P_LOCAL,
4188 .ptr = &sDefault.bSymlinks,
4189 .special = NULL,
4190 .enum_list = NULL,
4191 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4194 .label = "dont descend",
4195 .type = P_STRING,
4196 .p_class = P_LOCAL,
4197 .ptr = &sDefault.szDontdescend,
4198 .special = NULL,
4199 .enum_list = NULL,
4200 .flags = FLAG_ADVANCED | FLAG_SHARE,
4203 .label = "magic script",
4204 .type = P_STRING,
4205 .p_class = P_LOCAL,
4206 .ptr = &sDefault.szMagicScript,
4207 .special = NULL,
4208 .enum_list = NULL,
4209 .flags = FLAG_ADVANCED | FLAG_SHARE,
4212 .label = "magic output",
4213 .type = P_STRING,
4214 .p_class = P_LOCAL,
4215 .ptr = &sDefault.szMagicOutput,
4216 .special = NULL,
4217 .enum_list = NULL,
4218 .flags = FLAG_ADVANCED | FLAG_SHARE,
4221 .label = "delete readonly",
4222 .type = P_BOOL,
4223 .p_class = P_LOCAL,
4224 .ptr = &sDefault.bDeleteReadonly,
4225 .special = NULL,
4226 .enum_list = NULL,
4227 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4230 .label = "dos filemode",
4231 .type = P_BOOL,
4232 .p_class = P_LOCAL,
4233 .ptr = &sDefault.bDosFilemode,
4234 .special = NULL,
4235 .enum_list = NULL,
4236 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4239 .label = "dos filetimes",
4240 .type = P_BOOL,
4241 .p_class = P_LOCAL,
4242 .ptr = &sDefault.bDosFiletimes,
4243 .special = NULL,
4244 .enum_list = NULL,
4245 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4248 .label = "dos filetime resolution",
4249 .type = P_BOOL,
4250 .p_class = P_LOCAL,
4251 .ptr = &sDefault.bDosFiletimeResolution,
4252 .special = NULL,
4253 .enum_list = NULL,
4254 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4257 .label = "fake directory create times",
4258 .type = P_BOOL,
4259 .p_class = P_LOCAL,
4260 .ptr = &sDefault.bFakeDirCreateTimes,
4261 .special = NULL,
4262 .enum_list = NULL,
4263 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4266 .label = "panic action",
4267 .type = P_STRING,
4268 .p_class = P_GLOBAL,
4269 .ptr = &Globals.szPanicAction,
4270 .special = NULL,
4271 .enum_list = NULL,
4272 .flags = FLAG_ADVANCED,
4275 .label = "perfcount module",
4276 .type = P_STRING,
4277 .p_class = P_GLOBAL,
4278 .ptr = &Globals.szSMBPerfcountModule,
4279 .special = NULL,
4280 .enum_list = NULL,
4281 .flags = FLAG_ADVANCED,
4284 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4287 .label = "vfs objects",
4288 .type = P_LIST,
4289 .p_class = P_LOCAL,
4290 .ptr = &sDefault.szVfsObjects,
4291 .special = NULL,
4292 .enum_list = NULL,
4293 .flags = FLAG_ADVANCED | FLAG_SHARE,
4296 .label = "vfs object",
4297 .type = P_LIST,
4298 .p_class = P_LOCAL,
4299 .ptr = &sDefault.szVfsObjects,
4300 .special = NULL,
4301 .enum_list = NULL,
4302 .flags = FLAG_HIDE,
4306 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4309 .label = "msdfs root",
4310 .type = P_BOOL,
4311 .p_class = P_LOCAL,
4312 .ptr = &sDefault.bMSDfsRoot,
4313 .special = NULL,
4314 .enum_list = NULL,
4315 .flags = FLAG_ADVANCED | FLAG_SHARE,
4318 .label = "msdfs proxy",
4319 .type = P_STRING,
4320 .p_class = P_LOCAL,
4321 .ptr = &sDefault.szMSDfsProxy,
4322 .special = NULL,
4323 .enum_list = NULL,
4324 .flags = FLAG_ADVANCED | FLAG_SHARE,
4327 .label = "host msdfs",
4328 .type = P_BOOL,
4329 .p_class = P_GLOBAL,
4330 .ptr = &Globals.bHostMSDfs,
4331 .special = NULL,
4332 .enum_list = NULL,
4333 .flags = FLAG_ADVANCED,
4336 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4339 .label = "passdb expand explicit",
4340 .type = P_BOOL,
4341 .p_class = P_GLOBAL,
4342 .ptr = &Globals.bPassdbExpandExplicit,
4343 .special = NULL,
4344 .enum_list = NULL,
4345 .flags = FLAG_ADVANCED,
4348 .label = "idmap backend",
4349 .type = P_STRING,
4350 .p_class = P_GLOBAL,
4351 .ptr = &Globals.szIdmapBackend,
4352 .special = NULL,
4353 .enum_list = NULL,
4354 .flags = FLAG_ADVANCED,
4357 .label = "idmap alloc backend",
4358 .type = P_STRING,
4359 .p_class = P_GLOBAL,
4360 .ptr = &Globals.szIdmapAllocBackend,
4361 .special = NULL,
4362 .enum_list = NULL,
4363 .flags = FLAG_ADVANCED,
4366 .label = "idmap cache time",
4367 .type = P_INTEGER,
4368 .p_class = P_GLOBAL,
4369 .ptr = &Globals.iIdmapCacheTime,
4370 .special = NULL,
4371 .enum_list = NULL,
4372 .flags = FLAG_ADVANCED,
4375 .label = "idmap negative cache time",
4376 .type = P_INTEGER,
4377 .p_class = P_GLOBAL,
4378 .ptr = &Globals.iIdmapNegativeCacheTime,
4379 .special = NULL,
4380 .enum_list = NULL,
4381 .flags = FLAG_ADVANCED,
4384 .label = "idmap uid",
4385 .type = P_STRING,
4386 .p_class = P_GLOBAL,
4387 .ptr = &Globals.szIdmapUID,
4388 .special = handle_idmap_uid,
4389 .enum_list = NULL,
4390 .flags = FLAG_ADVANCED,
4393 .label = "winbind uid",
4394 .type = P_STRING,
4395 .p_class = P_GLOBAL,
4396 .ptr = &Globals.szIdmapUID,
4397 .special = handle_idmap_uid,
4398 .enum_list = NULL,
4399 .flags = FLAG_HIDE,
4402 .label = "idmap gid",
4403 .type = P_STRING,
4404 .p_class = P_GLOBAL,
4405 .ptr = &Globals.szIdmapGID,
4406 .special = handle_idmap_gid,
4407 .enum_list = NULL,
4408 .flags = FLAG_ADVANCED,
4411 .label = "winbind gid",
4412 .type = P_STRING,
4413 .p_class = P_GLOBAL,
4414 .ptr = &Globals.szIdmapGID,
4415 .special = handle_idmap_gid,
4416 .enum_list = NULL,
4417 .flags = FLAG_HIDE,
4420 .label = "template homedir",
4421 .type = P_STRING,
4422 .p_class = P_GLOBAL,
4423 .ptr = &Globals.szTemplateHomedir,
4424 .special = NULL,
4425 .enum_list = NULL,
4426 .flags = FLAG_ADVANCED,
4429 .label = "template shell",
4430 .type = P_STRING,
4431 .p_class = P_GLOBAL,
4432 .ptr = &Globals.szTemplateShell,
4433 .special = NULL,
4434 .enum_list = NULL,
4435 .flags = FLAG_ADVANCED,
4438 .label = "winbind separator",
4439 .type = P_STRING,
4440 .p_class = P_GLOBAL,
4441 .ptr = &Globals.szWinbindSeparator,
4442 .special = NULL,
4443 .enum_list = NULL,
4444 .flags = FLAG_ADVANCED,
4447 .label = "winbind cache time",
4448 .type = P_INTEGER,
4449 .p_class = P_GLOBAL,
4450 .ptr = &Globals.winbind_cache_time,
4451 .special = NULL,
4452 .enum_list = NULL,
4453 .flags = FLAG_ADVANCED,
4456 .label = "winbind reconnect delay",
4457 .type = P_INTEGER,
4458 .p_class = P_GLOBAL,
4459 .ptr = &Globals.winbind_reconnect_delay,
4460 .special = NULL,
4461 .enum_list = NULL,
4462 .flags = FLAG_ADVANCED,
4465 .label = "winbind enum users",
4466 .type = P_BOOL,
4467 .p_class = P_GLOBAL,
4468 .ptr = &Globals.bWinbindEnumUsers,
4469 .special = NULL,
4470 .enum_list = NULL,
4471 .flags = FLAG_ADVANCED,
4474 .label = "winbind enum groups",
4475 .type = P_BOOL,
4476 .p_class = P_GLOBAL,
4477 .ptr = &Globals.bWinbindEnumGroups,
4478 .special = NULL,
4479 .enum_list = NULL,
4480 .flags = FLAG_ADVANCED,
4483 .label = "winbind use default domain",
4484 .type = P_BOOL,
4485 .p_class = P_GLOBAL,
4486 .ptr = &Globals.bWinbindUseDefaultDomain,
4487 .special = NULL,
4488 .enum_list = NULL,
4489 .flags = FLAG_ADVANCED,
4492 .label = "winbind trusted domains only",
4493 .type = P_BOOL,
4494 .p_class = P_GLOBAL,
4495 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4496 .special = NULL,
4497 .enum_list = NULL,
4498 .flags = FLAG_ADVANCED,
4501 .label = "winbind nested groups",
4502 .type = P_BOOL,
4503 .p_class = P_GLOBAL,
4504 .ptr = &Globals.bWinbindNestedGroups,
4505 .special = NULL,
4506 .enum_list = NULL,
4507 .flags = FLAG_ADVANCED,
4510 .label = "winbind expand groups",
4511 .type = P_INTEGER,
4512 .p_class = P_GLOBAL,
4513 .ptr = &Globals.winbind_expand_groups,
4514 .special = NULL,
4515 .enum_list = NULL,
4516 .flags = FLAG_ADVANCED,
4519 .label = "winbind nss info",
4520 .type = P_LIST,
4521 .p_class = P_GLOBAL,
4522 .ptr = &Globals.szWinbindNssInfo,
4523 .special = NULL,
4524 .enum_list = NULL,
4525 .flags = FLAG_ADVANCED,
4528 .label = "winbind refresh tickets",
4529 .type = P_BOOL,
4530 .p_class = P_GLOBAL,
4531 .ptr = &Globals.bWinbindRefreshTickets,
4532 .special = NULL,
4533 .enum_list = NULL,
4534 .flags = FLAG_ADVANCED,
4537 .label = "winbind offline logon",
4538 .type = P_BOOL,
4539 .p_class = P_GLOBAL,
4540 .ptr = &Globals.bWinbindOfflineLogon,
4541 .special = NULL,
4542 .enum_list = NULL,
4543 .flags = FLAG_ADVANCED,
4546 .label = "winbind normalize names",
4547 .type = P_BOOL,
4548 .p_class = P_GLOBAL,
4549 .ptr = &Globals.bWinbindNormalizeNames,
4550 .special = NULL,
4551 .enum_list = NULL,
4552 .flags = FLAG_ADVANCED,
4555 .label = "winbind rpc only",
4556 .type = P_BOOL,
4557 .p_class = P_GLOBAL,
4558 .ptr = &Globals.bWinbindRpcOnly,
4559 .special = NULL,
4560 .enum_list = NULL,
4561 .flags = FLAG_ADVANCED,
4564 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4567 /***************************************************************************
4568 Initialise the sDefault parameter structure for the printer values.
4569 ***************************************************************************/
4571 static void init_printer_values(struct service *pService)
4573 /* choose defaults depending on the type of printing */
4574 switch (pService->iPrinting) {
4575 case PRINT_BSD:
4576 case PRINT_AIX:
4577 case PRINT_LPRNT:
4578 case PRINT_LPROS2:
4579 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4580 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4581 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4582 break;
4584 case PRINT_LPRNG:
4585 case PRINT_PLP:
4586 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4587 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4588 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4589 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4590 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4591 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4592 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4593 break;
4595 case PRINT_CUPS:
4596 case PRINT_IPRINT:
4597 #ifdef HAVE_CUPS
4598 /* set the lpq command to contain the destination printer
4599 name only. This is used by cups_queue_get() */
4600 string_set(&pService->szLpqcommand, "%p");
4601 string_set(&pService->szLprmcommand, "");
4602 string_set(&pService->szPrintcommand, "");
4603 string_set(&pService->szLppausecommand, "");
4604 string_set(&pService->szLpresumecommand, "");
4605 string_set(&pService->szQueuepausecommand, "");
4606 string_set(&pService->szQueueresumecommand, "");
4607 #else
4608 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4609 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4610 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4611 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4612 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4613 string_set(&pService->szQueuepausecommand, "disable '%p'");
4614 string_set(&pService->szQueueresumecommand, "enable '%p'");
4615 #endif /* HAVE_CUPS */
4616 break;
4618 case PRINT_SYSV:
4619 case PRINT_HPUX:
4620 string_set(&pService->szLpqcommand, "lpstat -o%p");
4621 string_set(&pService->szLprmcommand, "cancel %p-%j");
4622 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4623 string_set(&pService->szQueuepausecommand, "disable %p");
4624 string_set(&pService->szQueueresumecommand, "enable %p");
4625 #ifndef HPUX
4626 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4627 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4628 #endif /* HPUX */
4629 break;
4631 case PRINT_QNX:
4632 string_set(&pService->szLpqcommand, "lpq -P%p");
4633 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4634 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4635 break;
4637 #ifdef DEVELOPER
4638 case PRINT_TEST:
4639 case PRINT_VLP:
4640 string_set(&pService->szPrintcommand, "vlp print %p %s");
4641 string_set(&pService->szLpqcommand, "vlp lpq %p");
4642 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4643 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4644 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4645 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4646 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4647 break;
4648 #endif /* DEVELOPER */
4653 * Function to return the default value for the maximum number of open
4654 * file descriptors permitted. This function tries to consult the
4655 * kernel-level (sysctl) and ulimit (getrlimit()) values and goes
4656 * the smaller of those.
4658 static int max_open_files(void)
4660 int sysctl_max = MAX_OPEN_FILES;
4661 int rlimit_max = MAX_OPEN_FILES;
4663 #ifdef HAVE_SYSCTLBYNAME
4665 size_t size = sizeof(sysctl_max);
4666 sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,
4669 #endif
4671 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
4673 struct rlimit rl;
4675 ZERO_STRUCT(rl);
4677 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
4678 rlimit_max = rl.rlim_cur;
4680 #if defined(RLIM_INFINITY)
4681 if(rl.rlim_cur == RLIM_INFINITY)
4682 rlimit_max = MAX_OPEN_FILES;
4684 #endif
4685 #endif
4687 return MIN(sysctl_max, rlimit_max);
4691 * Common part of freeing allocated data for one parameter.
4693 static void free_one_parameter_common(void *parm_ptr,
4694 struct parm_struct parm)
4696 if ((parm.type == P_STRING) ||
4697 (parm.type == P_USTRING))
4699 string_free((char**)parm_ptr);
4700 } else if (parm.type == P_LIST) {
4701 TALLOC_FREE(*((char***)parm_ptr));
4706 * Free the allocated data for one parameter for a share
4707 * given as a service struct.
4709 static void free_one_parameter(struct service *service,
4710 struct parm_struct parm)
4712 void *parm_ptr;
4714 if (parm.p_class != P_LOCAL) {
4715 return;
4718 parm_ptr = lp_local_ptr(service, parm.ptr);
4720 free_one_parameter_common(parm_ptr, parm);
4724 * Free the allocated parameter data of a share given
4725 * as a service struct.
4727 static void free_parameters(struct service *service)
4729 uint32_t i;
4731 for (i=0; parm_table[i].label; i++) {
4732 free_one_parameter(service, parm_table[i]);
4737 * Free the allocated data for one parameter for a given share
4738 * specified by an snum.
4740 static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
4742 void *parm_ptr;
4744 if (parm.ptr == NULL) {
4745 return;
4748 if (snum < 0) {
4749 parm_ptr = parm.ptr;
4750 } else if (parm.p_class != P_LOCAL) {
4751 return;
4752 } else {
4753 parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
4756 free_one_parameter_common(parm_ptr, parm);
4760 * Free the allocated parameter data for a share specified
4761 * by an snum.
4763 static void free_parameters_by_snum(int snum)
4765 uint32_t i;
4767 for (i=0; parm_table[i].label; i++) {
4768 free_one_parameter_by_snum(snum, parm_table[i]);
4773 * Free the allocated global parameters.
4775 static void free_global_parameters(void)
4777 free_parameters_by_snum(GLOBAL_SECTION_SNUM);
4780 /***************************************************************************
4781 Initialise the global parameter structure.
4782 ***************************************************************************/
4784 static void init_globals(bool first_time_only)
4786 static bool done_init = False;
4787 char *s = NULL;
4788 int i;
4790 /* If requested to initialize only once and we've already done it... */
4791 if (first_time_only && done_init) {
4792 /* ... then we have nothing more to do */
4793 return;
4796 if (!done_init) {
4797 /* The logfile can be set before this is invoked. Free it if so. */
4798 if (Globals.szLogFile != NULL) {
4799 string_free(&Globals.szLogFile);
4800 Globals.szLogFile = NULL;
4802 done_init = True;
4803 } else {
4804 free_global_parameters();
4807 memset((void *)&Globals, '\0', sizeof(Globals));
4809 for (i = 0; parm_table[i].label; i++) {
4810 if ((parm_table[i].type == P_STRING ||
4811 parm_table[i].type == P_USTRING) &&
4812 parm_table[i].ptr)
4814 string_set((char **)parm_table[i].ptr, "");
4818 string_set(&sDefault.fstype, FSTYPE_STRING);
4819 string_set(&sDefault.szPrintjobUsername, "%U");
4821 init_printer_values(&sDefault);
4824 DEBUG(3, ("Initialising global parameters\n"));
4826 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4827 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4829 /* use the new 'hash2' method by default, with a prefix of 1 */
4830 string_set(&Globals.szManglingMethod, "hash2");
4831 Globals.mangle_prefix = 1;
4833 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4835 /* using UTF8 by default allows us to support all chars */
4836 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4838 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4839 /* If the system supports nl_langinfo(), try to grab the value
4840 from the user's locale */
4841 string_set(&Globals.display_charset, "LOCALE");
4842 #else
4843 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4844 #endif
4846 /* Use codepage 850 as a default for the dos character set */
4847 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4850 * Allow the default PASSWD_CHAT to be overridden in local.h.
4852 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4854 set_global_myname(myhostname());
4855 string_set(&Globals.szNetbiosName,global_myname());
4857 set_global_myworkgroup(WORKGROUP);
4858 string_set(&Globals.szWorkgroup, lp_workgroup());
4860 string_set(&Globals.szPasswdProgram, "");
4861 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4862 string_set(&Globals.szStateDir, get_dyn_STATEDIR());
4863 string_set(&Globals.szCacheDir, get_dyn_CACHEDIR());
4864 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4865 string_set(&Globals.szSocketAddress, "0.0.0.0");
4867 if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
4868 smb_panic("init_globals: ENOMEM");
4870 string_set(&Globals.szServerString, s);
4871 SAFE_FREE(s);
4872 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4873 DEFAULT_MINOR_VERSION) < 0) {
4874 smb_panic("init_globals: ENOMEM");
4876 string_set(&Globals.szAnnounceVersion, s);
4877 SAFE_FREE(s);
4878 #ifdef DEVELOPER
4879 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4880 #endif
4882 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4884 string_set(&Globals.szLogonDrive, "");
4885 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4886 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4887 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4889 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4890 string_set(&Globals.szPasswordServer, "*");
4892 Globals.AlgorithmicRidBase = BASE_RID;
4894 Globals.bLoadPrinters = True;
4895 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4897 Globals.ConfigBackend = config_backend;
4899 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4900 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4901 Globals.max_xmit = 0x4104;
4902 Globals.max_mux = 50; /* This is *needed* for profile support. */
4903 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4904 Globals.bDisableSpoolss = False;
4905 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4906 Globals.pwordlevel = 0;
4907 Globals.unamelevel = 0;
4908 Globals.deadtime = 0;
4909 Globals.getwd_cache = true;
4910 Globals.bLargeReadwrite = True;
4911 Globals.max_log_size = 5000;
4912 Globals.max_open_files = max_open_files();
4913 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4914 Globals.maxprotocol = PROTOCOL_NT1;
4915 Globals.minprotocol = PROTOCOL_CORE;
4916 Globals.security = SEC_USER;
4917 Globals.paranoid_server_security = True;
4918 Globals.bEncryptPasswords = True;
4919 Globals.bUpdateEncrypt = False;
4920 Globals.clientSchannel = Auto;
4921 Globals.serverSchannel = Auto;
4922 Globals.bReadRaw = True;
4923 Globals.bWriteRaw = True;
4924 Globals.bNullPasswords = False;
4925 Globals.bObeyPamRestrictions = False;
4926 Globals.syslog = 1;
4927 Globals.bSyslogOnly = False;
4928 Globals.bTimestampLogs = True;
4929 string_set(&Globals.szLogLevel, "0");
4930 Globals.bDebugPrefixTimestamp = False;
4931 Globals.bDebugHiresTimestamp = False;
4932 Globals.bDebugPid = False;
4933 Globals.bDebugUid = False;
4934 Globals.bDebugClass = False;
4935 Globals.bEnableCoreFiles = True;
4936 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4937 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4938 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4939 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4940 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4941 Globals.lm_interval = 60;
4942 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4943 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4944 Globals.bNISHomeMap = False;
4945 #ifdef WITH_NISPLUS_HOME
4946 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4947 #else
4948 string_set(&Globals.szNISHomeMapName, "auto.home");
4949 #endif
4950 #endif
4951 Globals.bTimeServer = False;
4952 Globals.bBindInterfacesOnly = False;
4953 Globals.bUnixPasswdSync = False;
4954 Globals.bPamPasswordChange = False;
4955 Globals.bPasswdChatDebug = False;
4956 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4957 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
4958 Globals.bNTStatusSupport = True; /* Use NT status by default. */
4959 Globals.bStatCache = True; /* use stat cache by default */
4960 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4961 Globals.restrict_anonymous = 0;
4962 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
4963 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
4964 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
4965 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4966 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
4967 /* Note, that we will use NTLM2 session security (which is different), if it is available */
4969 Globals.map_to_guest = 0; /* By Default, "Never" */
4970 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4971 Globals.enhanced_browsing = true;
4972 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4973 #ifdef MMAP_BLACKLIST
4974 Globals.bUseMmap = False;
4975 #else
4976 Globals.bUseMmap = True;
4977 #endif
4978 Globals.bUnixExtensions = True;
4979 Globals.bResetOnZeroVC = False;
4981 /* hostname lookups can be very expensive and are broken on
4982 a large number of sites (tridge) */
4983 Globals.bHostnameLookups = False;
4985 string_set(&Globals.szPassdbBackend, "smbpasswd");
4986 string_set(&Globals.szLdapSuffix, "");
4987 string_set(&Globals.szLdapMachineSuffix, "");
4988 string_set(&Globals.szLdapUserSuffix, "");
4989 string_set(&Globals.szLdapGroupSuffix, "");
4990 string_set(&Globals.szLdapIdmapSuffix, "");
4992 string_set(&Globals.szLdapAdminDn, "");
4993 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4994 Globals.ldap_ssl_ads = False;
4995 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4996 Globals.ldap_delete_dn = False;
4997 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4998 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4999 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
5000 Globals.ldap_page_size = LDAP_PAGE_SIZE;
5002 Globals.ldap_debug_level = 0;
5003 Globals.ldap_debug_threshold = 10;
5005 /* This is what we tell the afs client. in reality we set the token
5006 * to never expire, though, when this runs out the afs client will
5007 * forget the token. Set to 0 to get NEVERDATE.*/
5008 Globals.iAfsTokenLifetime = 604800;
5009 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
5011 /* these parameters are set to defaults that are more appropriate
5012 for the increasing samba install base:
5014 as a member of the workgroup, that will possibly become a
5015 _local_ master browser (lm = True). this is opposed to a forced
5016 local master browser startup (pm = True).
5018 doesn't provide WINS server service by default (wsupp = False),
5019 and doesn't provide domain master browser services by default, either.
5023 Globals.bMsAddPrinterWizard = True;
5024 Globals.os_level = 20;
5025 Globals.bLocalMaster = True;
5026 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
5027 Globals.bDomainLogons = False;
5028 Globals.bBrowseList = True;
5029 Globals.bWINSsupport = False;
5030 Globals.bWINSproxy = False;
5032 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
5033 Globals.InitLogonDelay = 100; /* 100 ms default delay */
5035 Globals.bDNSproxy = True;
5037 /* this just means to use them if they exist */
5038 Globals.bKernelOplocks = True;
5040 Globals.bAllowTrustedDomains = True;
5041 string_set(&Globals.szIdmapBackend, "tdb");
5043 string_set(&Globals.szTemplateShell, "/bin/false");
5044 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
5045 string_set(&Globals.szWinbindSeparator, "\\");
5047 string_set(&Globals.szCupsServer, "");
5048 string_set(&Globals.szIPrintServer, "");
5050 string_set(&Globals.ctdbdSocket, "");
5051 Globals.szClusterAddresses = NULL;
5052 Globals.clustering = False;
5054 Globals.winbind_cache_time = 300; /* 5 minutes */
5055 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
5056 Globals.bWinbindEnumUsers = False;
5057 Globals.bWinbindEnumGroups = False;
5058 Globals.bWinbindUseDefaultDomain = False;
5059 Globals.bWinbindTrustedDomainsOnly = False;
5060 Globals.bWinbindNestedGroups = True;
5061 Globals.winbind_expand_groups = 1;
5062 Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
5063 Globals.bWinbindRefreshTickets = False;
5064 Globals.bWinbindOfflineLogon = False;
5066 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
5067 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
5069 Globals.bPassdbExpandExplicit = False;
5071 Globals.name_cache_timeout = 660; /* In seconds */
5073 Globals.bUseSpnego = True;
5074 Globals.bClientUseSpnego = True;
5076 Globals.client_signing = Auto;
5077 Globals.server_signing = False;
5079 Globals.bDeferSharingViolations = True;
5080 string_set(&Globals.smb_ports, SMB_PORTS);
5082 Globals.bEnablePrivileges = True;
5083 Globals.bHostMSDfs = True;
5084 Globals.bASUSupport = False;
5086 /* User defined shares. */
5087 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
5088 smb_panic("init_globals: ENOMEM");
5090 string_set(&Globals.szUsersharePath, s);
5091 SAFE_FREE(s);
5092 string_set(&Globals.szUsershareTemplateShare, "");
5093 Globals.iUsershareMaxShares = 0;
5094 /* By default disallow sharing of directories not owned by the sharer. */
5095 Globals.bUsershareOwnerOnly = True;
5096 /* By default disallow guest access to usershares. */
5097 Globals.bUsershareAllowGuests = False;
5099 Globals.iKeepalive = DEFAULT_KEEPALIVE;
5101 /* By default no shares out of the registry */
5102 Globals.bRegistryShares = False;
5104 Globals.iminreceivefile = 0;
5106 Globals.bMapUntrustedToDomain = false;
5109 /*******************************************************************
5110 Convenience routine to grab string parameters into temporary memory
5111 and run standard_sub_basic on them. The buffers can be written to by
5112 callers without affecting the source string.
5113 ********************************************************************/
5115 static char *lp_string(const char *s)
5117 char *ret;
5118 TALLOC_CTX *ctx = talloc_tos();
5120 /* The follow debug is useful for tracking down memory problems
5121 especially if you have an inner loop that is calling a lp_*()
5122 function that returns a string. Perhaps this debug should be
5123 present all the time? */
5125 #if 0
5126 DEBUG(10, ("lp_string(%s)\n", s));
5127 #endif
5129 ret = talloc_sub_basic(ctx,
5130 get_current_username(),
5131 current_user_info.domain,
5133 if (trim_char(ret, '\"', '\"')) {
5134 if (strchr(ret,'\"') != NULL) {
5135 TALLOC_FREE(ret);
5136 ret = talloc_sub_basic(ctx,
5137 get_current_username(),
5138 current_user_info.domain,
5142 return ret;
5146 In this section all the functions that are used to access the
5147 parameters from the rest of the program are defined
5150 #define FN_GLOBAL_STRING(fn_name,ptr) \
5151 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5152 #define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5153 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5154 #define FN_GLOBAL_LIST(fn_name,ptr) \
5155 const char **fn_name(void) {return(*(const char ***)(ptr));}
5156 #define FN_GLOBAL_BOOL(fn_name,ptr) \
5157 bool fn_name(void) {return(*(bool *)(ptr));}
5158 #define FN_GLOBAL_CHAR(fn_name,ptr) \
5159 char fn_name(void) {return(*(char *)(ptr));}
5160 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
5161 int fn_name(void) {return(*(int *)(ptr));}
5163 #define FN_LOCAL_STRING(fn_name,val) \
5164 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5165 #define FN_LOCAL_CONST_STRING(fn_name,val) \
5166 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5167 #define FN_LOCAL_LIST(fn_name,val) \
5168 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5169 #define FN_LOCAL_BOOL(fn_name,val) \
5170 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5171 #define FN_LOCAL_INTEGER(fn_name,val) \
5172 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5174 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
5175 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5176 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5177 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5178 #define FN_LOCAL_PARM_STRING(fn_name,val) \
5179 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));}
5180 #define FN_LOCAL_CHAR(fn_name,val) \
5181 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5183 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5184 FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5185 FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5186 FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5187 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5188 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5189 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5190 FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5191 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5192 FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5193 FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5194 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5195 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5196 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5197 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5198 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5199 /* If lp_statedir() and lp_cachedir() are explicitely set during the
5200 * build process or in smb.conf, we use that value. Otherwise they
5201 * default to the value of lp_lockdir(). */
5202 char *lp_statedir(void) {
5203 if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
5204 (strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
5205 return(lp_string(*(char **)(&Globals.szStateDir) ?
5206 *(char **)(&Globals.szStateDir) : ""));
5207 else
5208 return(lp_string(*(char **)(&Globals.szLockDir) ?
5209 *(char **)(&Globals.szLockDir) : ""));
5211 char *lp_cachedir(void) {
5212 if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
5213 (strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
5214 return(lp_string(*(char **)(&Globals.szCacheDir) ?
5215 *(char **)(&Globals.szCacheDir) : ""));
5216 else
5217 return(lp_string(*(char **)(&Globals.szLockDir) ?
5218 *(char **)(&Globals.szLockDir) : ""));
5220 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5221 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5222 FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5223 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5224 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5225 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5226 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5227 FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
5228 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5229 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5230 FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5231 FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5232 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5233 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5234 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5235 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5236 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5237 FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5238 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5239 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5240 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5241 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5242 FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5243 FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5244 FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5245 FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5246 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5247 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5248 FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5249 FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5250 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5251 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5252 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5253 /* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5254 * lp_passdb_backend() should be replace by the this macro again after
5255 * some releases.
5256 * */
5257 const char *lp_passdb_backend(void)
5259 char *delim, *quote;
5261 delim = strchr( Globals.szPassdbBackend, ' ');
5262 /* no space at all */
5263 if (delim == NULL) {
5264 goto out;
5267 quote = strchr(Globals.szPassdbBackend, '"');
5268 /* no quote char or non in the first part */
5269 if (quote == NULL || quote > delim) {
5270 *delim = '\0';
5271 goto warn;
5274 quote = strchr(quote+1, '"');
5275 if (quote == NULL) {
5276 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5277 goto out;
5278 } else if (*(quote+1) == '\0') {
5279 /* space, fitting quote char, and one backend only */
5280 goto out;
5281 } else {
5282 /* terminate string after the fitting quote char */
5283 *(quote+1) = '\0';
5286 warn:
5287 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5288 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5289 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5290 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5292 out:
5293 return Globals.szPassdbBackend;
5295 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5296 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5297 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5298 FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5299 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5301 FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5302 FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5303 FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5304 FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5305 FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5306 FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5308 FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5310 FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5311 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5312 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5314 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5316 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5317 FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5318 FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5319 FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5320 FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5321 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5322 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5323 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5324 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5325 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5326 FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5327 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5328 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5329 FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5330 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5332 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5333 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5334 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5335 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5336 FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5337 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5339 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5340 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5341 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5342 FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5343 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5344 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5345 FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5346 FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5347 FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5348 FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5349 FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5350 FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5351 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5352 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5353 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5354 FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5355 FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5356 FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5358 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5360 FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5361 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5362 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5363 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5364 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5365 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5366 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5367 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5368 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5369 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5370 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5371 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5372 FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5373 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5374 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5375 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5376 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5377 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5378 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5379 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5380 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5381 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5382 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5383 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5384 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5385 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5386 FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5387 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5388 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5389 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5390 FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5391 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5392 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5393 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5394 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5395 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5396 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5397 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5398 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5399 FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5400 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5401 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5402 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5403 FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5404 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5405 FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
5406 FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5407 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5408 FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5409 FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5410 FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5411 FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5412 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5413 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5414 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5415 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5416 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5417 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5418 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5419 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5420 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5421 FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5422 FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
5423 FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
5424 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5425 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5426 FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5427 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5428 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5429 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5430 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5431 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5432 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5433 FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5434 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5435 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5436 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5437 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5438 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5439 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5440 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5441 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5442 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5443 FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5444 FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5445 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5446 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5447 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5448 FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5449 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5450 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5451 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5452 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5453 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5454 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5455 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5456 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5457 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5458 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5459 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5461 FN_LOCAL_STRING(lp_preexec, szPreExec)
5462 FN_LOCAL_STRING(lp_postexec, szPostExec)
5463 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5464 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5465 FN_LOCAL_STRING(lp_servicename, szService)
5466 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5467 FN_LOCAL_STRING(lp_pathname, szPath)
5468 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5469 FN_LOCAL_STRING(lp_username, szUsername)
5470 FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5471 FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5472 FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5473 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5474 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5475 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5476 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5477 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5478 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5479 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5480 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5481 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5482 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5483 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5484 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5485 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5486 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5487 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5488 static FN_LOCAL_STRING(_lp_printername, szPrintername)
5489 FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5490 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5491 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5492 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5493 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5494 FN_LOCAL_STRING(lp_comment, comment)
5495 FN_LOCAL_STRING(lp_force_user, force_user)
5496 FN_LOCAL_STRING(lp_force_group, force_group)
5497 FN_LOCAL_LIST(lp_readlist, readlist)
5498 FN_LOCAL_LIST(lp_writelist, writelist)
5499 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5500 FN_LOCAL_STRING(lp_fstype, fstype)
5501 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5502 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5503 static FN_LOCAL_STRING(lp_volume, volume)
5504 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5505 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5506 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5507 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5508 FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5509 FN_LOCAL_STRING(lp_dfree_command, szDfree)
5510 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5511 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5512 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5513 FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5514 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5515 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5516 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5517 FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5518 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5519 FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5520 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5521 FN_LOCAL_BOOL(lp_access_based_share_enum, bAccessBasedShareEnum)
5522 FN_LOCAL_BOOL(lp_readonly, bRead_only)
5523 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5524 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5525 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5526 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5527 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5528 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5529 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5530 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5531 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5532 FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5533 FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5534 FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5535 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5536 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5537 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5538 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5539 FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5540 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
5541 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5542 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5543 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5544 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5545 FN_LOCAL_BOOL(lp_map_system, bMap_system)
5546 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5547 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5548 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5549 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5550 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5551 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5552 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5553 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5554 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5555 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5556 FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5557 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5558 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5559 FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5560 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5561 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5562 FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5563 FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5564 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5565 FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5566 FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5567 FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5568 FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5569 FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5570 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5571 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5572 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5573 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5574 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5575 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5576 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5577 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5578 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5579 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5580 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5581 FN_LOCAL_INTEGER(lp_printing, iPrinting)
5582 FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5583 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5584 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5585 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5586 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5587 FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5588 FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5589 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5590 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5591 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5592 FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5593 FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5594 FN_LOCAL_CHAR(lp_magicchar, magic_char)
5595 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5596 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5597 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5598 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5599 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5600 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5601 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5602 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5604 /* local prototypes */
5606 static int map_parameter(const char *pszParmName);
5607 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5608 static const char *get_boolean(bool bool_value);
5609 static int getservicebyname(const char *pszServiceName,
5610 struct service *pserviceDest);
5611 static void copy_service(struct service *pserviceDest,
5612 struct service *pserviceSource,
5613 struct bitmap *pcopymapDest);
5614 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5615 void *userdata);
5616 static bool do_section(const char *pszSectionName, void *userdata);
5617 static void init_copymap(struct service *pservice);
5618 static bool hash_a_service(const char *name, int number);
5619 static void free_service_byindex(int iService);
5620 static void free_param_opts(struct param_opt_struct **popts);
5621 static char * canonicalize_servicename(const char *name);
5622 static void show_parameter(int parmIndex);
5623 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5626 * This is a helper function for parametrical options support. It returns a
5627 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5628 * parametrical functions are quite simple
5630 static struct param_opt_struct *get_parametrics(int snum, const char *type,
5631 const char *option)
5633 bool global_section = False;
5634 char* param_key;
5635 struct param_opt_struct *data;
5637 if (snum >= iNumServices) return NULL;
5639 if (snum < 0) {
5640 data = Globals.param_opt;
5641 global_section = True;
5642 } else {
5643 data = ServicePtrs[snum]->param_opt;
5646 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5647 DEBUG(0,("asprintf failed!\n"));
5648 return NULL;
5651 while (data) {
5652 if (strwicmp(data->key, param_key) == 0) {
5653 string_free(&param_key);
5654 return data;
5656 data = data->next;
5659 if (!global_section) {
5660 /* Try to fetch the same option but from globals */
5661 /* but only if we are not already working with Globals */
5662 data = Globals.param_opt;
5663 while (data) {
5664 if (strwicmp(data->key, param_key) == 0) {
5665 string_free(&param_key);
5666 return data;
5668 data = data->next;
5672 string_free(&param_key);
5674 return NULL;
5678 #define MISSING_PARAMETER(name) \
5679 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5681 /*******************************************************************
5682 convenience routine to return int parameters.
5683 ********************************************************************/
5684 static int lp_int(const char *s)
5687 if (!s || !*s) {
5688 MISSING_PARAMETER(lp_int);
5689 return (-1);
5692 return (int)strtol(s, NULL, 0);
5695 /*******************************************************************
5696 convenience routine to return unsigned long parameters.
5697 ********************************************************************/
5698 static unsigned long lp_ulong(const char *s)
5701 if (!s || !*s) {
5702 MISSING_PARAMETER(lp_ulong);
5703 return (0);
5706 return strtoul(s, NULL, 0);
5709 /*******************************************************************
5710 convenience routine to return boolean parameters.
5711 ********************************************************************/
5712 static bool lp_bool(const char *s)
5714 bool ret = False;
5716 if (!s || !*s) {
5717 MISSING_PARAMETER(lp_bool);
5718 return False;
5721 if (!set_boolean(s, &ret)) {
5722 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5723 return False;
5726 return ret;
5729 /*******************************************************************
5730 convenience routine to return enum parameters.
5731 ********************************************************************/
5732 static int lp_enum(const char *s,const struct enum_list *_enum)
5734 int i;
5736 if (!s || !*s || !_enum) {
5737 MISSING_PARAMETER(lp_enum);
5738 return (-1);
5741 for (i=0; _enum[i].name; i++) {
5742 if (strequal(_enum[i].name,s))
5743 return _enum[i].value;
5746 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5747 return (-1);
5750 #undef MISSING_PARAMETER
5752 /* DO NOT USE lp_parm_string ANYMORE!!!!
5753 * use lp_parm_const_string or lp_parm_talloc_string
5755 * lp_parm_string is only used to let old modules find this symbol
5757 #undef lp_parm_string
5758 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5759 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5761 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5764 /* Return parametric option from a given service. Type is a part of option before ':' */
5765 /* Parametric option has following syntax: 'Type: option = value' */
5766 /* the returned value is talloced on the talloc_tos() */
5767 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5769 struct param_opt_struct *data = get_parametrics(snum, type, option);
5771 if (data == NULL||data->value==NULL) {
5772 if (def) {
5773 return lp_string(def);
5774 } else {
5775 return NULL;
5779 return lp_string(data->value);
5782 /* Return parametric option from a given service. Type is a part of option before ':' */
5783 /* Parametric option has following syntax: 'Type: option = value' */
5784 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5786 struct param_opt_struct *data = get_parametrics(snum, type, option);
5788 if (data == NULL||data->value==NULL)
5789 return def;
5791 return data->value;
5794 /* Return parametric option from a given service. Type is a part of option before ':' */
5795 /* Parametric option has following syntax: 'Type: option = value' */
5797 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5799 struct param_opt_struct *data = get_parametrics(snum, type, option);
5801 if (data == NULL||data->value==NULL)
5802 return (const char **)def;
5804 if (data->list==NULL) {
5805 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
5808 return (const char **)data->list;
5811 /* Return parametric option from a given service. Type is a part of option before ':' */
5812 /* Parametric option has following syntax: 'Type: option = value' */
5814 int lp_parm_int(int snum, const char *type, const char *option, int def)
5816 struct param_opt_struct *data = get_parametrics(snum, type, option);
5818 if (data && data->value && *data->value)
5819 return lp_int(data->value);
5821 return def;
5824 /* Return parametric option from a given service. Type is a part of option before ':' */
5825 /* Parametric option has following syntax: 'Type: option = value' */
5827 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5829 struct param_opt_struct *data = get_parametrics(snum, type, option);
5831 if (data && data->value && *data->value)
5832 return lp_ulong(data->value);
5834 return def;
5837 /* Return parametric option from a given service. Type is a part of option before ':' */
5838 /* Parametric option has following syntax: 'Type: option = value' */
5840 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5842 struct param_opt_struct *data = get_parametrics(snum, type, option);
5844 if (data && data->value && *data->value)
5845 return lp_bool(data->value);
5847 return def;
5850 /* Return parametric option from a given service. Type is a part of option before ':' */
5851 /* Parametric option has following syntax: 'Type: option = value' */
5853 int lp_parm_enum(int snum, const char *type, const char *option,
5854 const struct enum_list *_enum, int def)
5856 struct param_opt_struct *data = get_parametrics(snum, type, option);
5858 if (data && data->value && *data->value && _enum)
5859 return lp_enum(data->value, _enum);
5861 return def;
5865 /***************************************************************************
5866 Initialise a service to the defaults.
5867 ***************************************************************************/
5869 static void init_service(struct service *pservice)
5871 memset((char *)pservice, '\0', sizeof(struct service));
5872 copy_service(pservice, &sDefault, NULL);
5877 * free a param_opts structure.
5878 * param_opts handling should be moved to talloc;
5879 * then this whole functions reduces to a TALLOC_FREE().
5882 static void free_param_opts(struct param_opt_struct **popts)
5884 struct param_opt_struct *opt, *next_opt;
5886 if (popts == NULL) {
5887 return;
5890 if (*popts != NULL) {
5891 DEBUG(5, ("Freeing parametrics:\n"));
5893 opt = *popts;
5894 while (opt != NULL) {
5895 string_free(&opt->key);
5896 string_free(&opt->value);
5897 TALLOC_FREE(opt->list);
5898 next_opt = opt->next;
5899 SAFE_FREE(opt);
5900 opt = next_opt;
5902 *popts = NULL;
5905 /***************************************************************************
5906 Free the dynamically allocated parts of a service struct.
5907 ***************************************************************************/
5909 static void free_service(struct service *pservice)
5911 if (!pservice)
5912 return;
5914 if (pservice->szService)
5915 DEBUG(5, ("free_service: Freeing service %s\n",
5916 pservice->szService));
5918 free_parameters(pservice);
5920 string_free(&pservice->szService);
5921 bitmap_free(pservice->copymap);
5923 free_param_opts(&pservice->param_opt);
5925 ZERO_STRUCTP(pservice);
5929 /***************************************************************************
5930 remove a service indexed in the ServicePtrs array from the ServiceHash
5931 and free the dynamically allocated parts
5932 ***************************************************************************/
5934 static void free_service_byindex(int idx)
5936 if ( !LP_SNUM_OK(idx) )
5937 return;
5939 ServicePtrs[idx]->valid = False;
5940 invalid_services[num_invalid_services++] = idx;
5942 /* we have to cleanup the hash record */
5944 if (ServicePtrs[idx]->szService) {
5945 char *canon_name = canonicalize_servicename(
5946 ServicePtrs[idx]->szService );
5948 dbwrap_delete_bystring(ServiceHash, canon_name );
5949 TALLOC_FREE(canon_name);
5952 free_service(ServicePtrs[idx]);
5955 /***************************************************************************
5956 Add a new service to the services array initialising it with the given
5957 service.
5958 ***************************************************************************/
5960 static int add_a_service(const struct service *pservice, const char *name)
5962 int i;
5963 struct service tservice;
5964 int num_to_alloc = iNumServices + 1;
5966 tservice = *pservice;
5968 /* it might already exist */
5969 if (name) {
5970 i = getservicebyname(name, NULL);
5971 if (i >= 0) {
5972 /* Clean all parametric options for service */
5973 /* They will be added during parsing again */
5974 free_param_opts(&ServicePtrs[i]->param_opt);
5975 return (i);
5979 /* find an invalid one */
5980 i = iNumServices;
5981 if (num_invalid_services > 0) {
5982 i = invalid_services[--num_invalid_services];
5985 /* if not, then create one */
5986 if (i == iNumServices) {
5987 struct service **tsp;
5988 int *tinvalid;
5990 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
5991 if (tsp == NULL) {
5992 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5993 return (-1);
5995 ServicePtrs = tsp;
5996 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
5997 if (!ServicePtrs[iNumServices]) {
5998 DEBUG(0,("add_a_service: out of memory!\n"));
5999 return (-1);
6001 iNumServices++;
6003 /* enlarge invalid_services here for now... */
6004 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
6005 num_to_alloc);
6006 if (tinvalid == NULL) {
6007 DEBUG(0,("add_a_service: failed to enlarge "
6008 "invalid_services!\n"));
6009 return (-1);
6011 invalid_services = tinvalid;
6012 } else {
6013 free_service_byindex(i);
6016 ServicePtrs[i]->valid = True;
6018 init_service(ServicePtrs[i]);
6019 copy_service(ServicePtrs[i], &tservice, NULL);
6020 if (name)
6021 string_set(&ServicePtrs[i]->szService, name);
6023 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
6024 i, ServicePtrs[i]->szService));
6026 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
6027 return (-1);
6030 return (i);
6033 /***************************************************************************
6034 Convert a string to uppercase and remove whitespaces.
6035 ***************************************************************************/
6037 static char *canonicalize_servicename(const char *src)
6039 char *result;
6041 if ( !src ) {
6042 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
6043 return NULL;
6046 result = talloc_strdup(talloc_tos(), src);
6047 SMB_ASSERT(result != NULL);
6049 strlower_m(result);
6050 return result;
6053 /***************************************************************************
6054 Add a name/index pair for the services array to the hash table.
6055 ***************************************************************************/
6057 static bool hash_a_service(const char *name, int idx)
6059 char *canon_name;
6061 if ( !ServiceHash ) {
6062 DEBUG(10,("hash_a_service: creating servicehash\n"));
6063 ServiceHash = db_open_rbt(NULL);
6064 if ( !ServiceHash ) {
6065 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
6066 return False;
6070 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
6071 idx, name));
6073 canon_name = canonicalize_servicename( name );
6075 dbwrap_store_bystring(ServiceHash, canon_name,
6076 make_tdb_data((uint8 *)&idx, sizeof(idx)),
6077 TDB_REPLACE);
6079 TALLOC_FREE(canon_name);
6081 return True;
6084 /***************************************************************************
6085 Add a new home service, with the specified home directory, defaults coming
6086 from service ifrom.
6087 ***************************************************************************/
6089 bool lp_add_home(const char *pszHomename, int iDefaultService,
6090 const char *user, const char *pszHomedir)
6092 int i;
6094 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
6096 if (i < 0)
6097 return (False);
6099 if (!(*(ServicePtrs[iDefaultService]->szPath))
6100 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
6101 string_set(&ServicePtrs[i]->szPath, pszHomedir);
6104 if (!(*(ServicePtrs[i]->comment))) {
6105 char *comment = NULL;
6106 if (asprintf(&comment, "Home directory of %s", user) < 0) {
6107 return false;
6109 string_set(&ServicePtrs[i]->comment, comment);
6110 SAFE_FREE(comment);
6113 /* set the browseable flag from the global default */
6115 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6116 ServicePtrs[i]->bAccessBasedShareEnum = sDefault.bAccessBasedShareEnum;
6118 ServicePtrs[i]->autoloaded = True;
6120 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
6121 user, ServicePtrs[i]->szPath ));
6123 return (True);
6126 /***************************************************************************
6127 Add a new service, based on an old one.
6128 ***************************************************************************/
6130 int lp_add_service(const char *pszService, int iDefaultService)
6132 if (iDefaultService < 0) {
6133 return add_a_service(&sDefault, pszService);
6136 return (add_a_service(ServicePtrs[iDefaultService], pszService));
6139 /***************************************************************************
6140 Add the IPC service.
6141 ***************************************************************************/
6143 static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
6145 char *comment = NULL;
6146 int i = add_a_service(&sDefault, ipc_name);
6148 if (i < 0)
6149 return (False);
6151 if (asprintf(&comment, "IPC Service (%s)",
6152 Globals.szServerString) < 0) {
6153 return (False);
6156 string_set(&ServicePtrs[i]->szPath, tmpdir());
6157 string_set(&ServicePtrs[i]->szUsername, "");
6158 string_set(&ServicePtrs[i]->comment, comment);
6159 string_set(&ServicePtrs[i]->fstype, "IPC");
6160 ServicePtrs[i]->iMaxConnections = 0;
6161 ServicePtrs[i]->bAvailable = True;
6162 ServicePtrs[i]->bRead_only = True;
6163 ServicePtrs[i]->bGuest_only = False;
6164 ServicePtrs[i]->bAdministrative_share = True;
6165 ServicePtrs[i]->bGuest_ok = guest_ok;
6166 ServicePtrs[i]->bPrint_ok = False;
6167 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6169 DEBUG(3, ("adding IPC service\n"));
6171 SAFE_FREE(comment);
6172 return (True);
6175 /***************************************************************************
6176 Add a new printer service, with defaults coming from service iFrom.
6177 ***************************************************************************/
6179 bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6181 const char *comment = "From Printcap";
6182 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6184 if (i < 0)
6185 return (False);
6187 /* note that we do NOT default the availability flag to True - */
6188 /* we take it from the default service passed. This allows all */
6189 /* dynamic printers to be disabled by disabling the [printers] */
6190 /* entry (if/when the 'available' keyword is implemented!). */
6192 /* the printer name is set to the service name. */
6193 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6194 string_set(&ServicePtrs[i]->comment, comment);
6196 /* set the browseable flag from the gloabl default */
6197 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6199 /* Printers cannot be read_only. */
6200 ServicePtrs[i]->bRead_only = False;
6201 /* No share modes on printer services. */
6202 ServicePtrs[i]->bShareModes = False;
6203 /* No oplocks on printer services. */
6204 ServicePtrs[i]->bOpLocks = False;
6205 /* Printer services must be printable. */
6206 ServicePtrs[i]->bPrint_ok = True;
6208 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6210 return (True);
6214 /***************************************************************************
6215 Check whether the given parameter name is valid.
6216 Parametric options (names containing a colon) are considered valid.
6217 ***************************************************************************/
6219 bool lp_parameter_is_valid(const char *pszParmName)
6221 return ((map_parameter(pszParmName) != -1) ||
6222 (strchr(pszParmName, ':') != NULL));
6225 /***************************************************************************
6226 Check whether the given name is the name of a global parameter.
6227 Returns True for strings belonging to parameters of class
6228 P_GLOBAL, False for all other strings, also for parametric options
6229 and strings not belonging to any option.
6230 ***************************************************************************/
6232 bool lp_parameter_is_global(const char *pszParmName)
6234 int num = map_parameter(pszParmName);
6236 if (num >= 0) {
6237 return (parm_table[num].p_class == P_GLOBAL);
6240 return False;
6243 /**************************************************************************
6244 Check whether the given name is the canonical name of a parameter.
6245 Returns False if it is not a valid parameter Name.
6246 For parametric options, True is returned.
6247 **************************************************************************/
6249 bool lp_parameter_is_canonical(const char *parm_name)
6251 if (!lp_parameter_is_valid(parm_name)) {
6252 return False;
6255 return (map_parameter(parm_name) ==
6256 map_parameter_canonical(parm_name, NULL));
6259 /**************************************************************************
6260 Determine the canonical name for a parameter.
6261 Indicate when it is an inverse (boolean) synonym instead of a
6262 "usual" synonym.
6263 **************************************************************************/
6265 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6266 bool *inverse)
6268 int num;
6270 if (!lp_parameter_is_valid(parm_name)) {
6271 *canon_parm = NULL;
6272 return False;
6275 num = map_parameter_canonical(parm_name, inverse);
6276 if (num < 0) {
6277 /* parametric option */
6278 *canon_parm = parm_name;
6279 } else {
6280 *canon_parm = parm_table[num].label;
6283 return True;
6287 /**************************************************************************
6288 Determine the canonical name for a parameter.
6289 Turn the value given into the inverse boolean expression when
6290 the synonym is an invers boolean synonym.
6292 Return True if parm_name is a valid parameter name and
6293 in case it is an invers boolean synonym, if the val string could
6294 successfully be converted to the reverse bool.
6295 Return false in all other cases.
6296 **************************************************************************/
6298 bool lp_canonicalize_parameter_with_value(const char *parm_name,
6299 const char *val,
6300 const char **canon_parm,
6301 const char **canon_val)
6303 int num;
6304 bool inverse;
6306 if (!lp_parameter_is_valid(parm_name)) {
6307 *canon_parm = NULL;
6308 *canon_val = NULL;
6309 return False;
6312 num = map_parameter_canonical(parm_name, &inverse);
6313 if (num < 0) {
6314 /* parametric option */
6315 *canon_parm = parm_name;
6316 *canon_val = val;
6317 } else {
6318 *canon_parm = parm_table[num].label;
6319 if (inverse) {
6320 if (!lp_invert_boolean(val, canon_val)) {
6321 *canon_val = NULL;
6322 return False;
6324 } else {
6325 *canon_val = val;
6329 return True;
6332 /***************************************************************************
6333 Map a parameter's string representation to something we can use.
6334 Returns False if the parameter string is not recognised, else TRUE.
6335 ***************************************************************************/
6337 static int map_parameter(const char *pszParmName)
6339 int iIndex;
6341 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6342 return (-1);
6344 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6345 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6346 return (iIndex);
6348 /* Warn only if it isn't parametric option */
6349 if (strchr(pszParmName, ':') == NULL)
6350 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6351 /* We do return 'fail' for parametric options as well because they are
6352 stored in different storage
6354 return (-1);
6357 /***************************************************************************
6358 Map a parameter's string representation to the index of the canonical
6359 form of the parameter (it might be a synonym).
6360 Returns -1 if the parameter string is not recognised.
6361 ***************************************************************************/
6363 static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6365 int parm_num, canon_num;
6366 bool loc_inverse = False;
6368 parm_num = map_parameter(pszParmName);
6369 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6370 /* invalid, parametric or no canidate for synonyms ... */
6371 goto done;
6374 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6375 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6376 parm_num = canon_num;
6377 goto done;
6381 done:
6382 if (inverse != NULL) {
6383 *inverse = loc_inverse;
6385 return parm_num;
6388 /***************************************************************************
6389 return true if parameter number parm1 is a synonym of parameter
6390 number parm2 (parm2 being the principal name).
6391 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6392 False otherwise.
6393 ***************************************************************************/
6395 static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6397 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6398 (parm_table[parm1].flags & FLAG_HIDE) &&
6399 !(parm_table[parm2].flags & FLAG_HIDE))
6401 if (inverse != NULL) {
6402 if ((parm_table[parm1].type == P_BOOLREV) &&
6403 (parm_table[parm2].type == P_BOOL))
6405 *inverse = True;
6406 } else {
6407 *inverse = False;
6410 return True;
6412 return False;
6415 /***************************************************************************
6416 Show one parameter's name, type, [values,] and flags.
6417 (helper functions for show_parameter_list)
6418 ***************************************************************************/
6420 static void show_parameter(int parmIndex)
6422 int enumIndex, flagIndex;
6423 int parmIndex2;
6424 bool hadFlag;
6425 bool hadSyn;
6426 bool inverse;
6427 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6428 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6429 "P_ENUM", "P_SEP"};
6430 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6431 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6432 FLAG_HIDE, FLAG_DOS_STRING};
6433 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6434 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6435 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6437 printf("%s=%s", parm_table[parmIndex].label,
6438 type[parm_table[parmIndex].type]);
6439 if (parm_table[parmIndex].type == P_ENUM) {
6440 printf(",");
6441 for (enumIndex=0;
6442 parm_table[parmIndex].enum_list[enumIndex].name;
6443 enumIndex++)
6445 printf("%s%s",
6446 enumIndex ? "|" : "",
6447 parm_table[parmIndex].enum_list[enumIndex].name);
6450 printf(",");
6451 hadFlag = False;
6452 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6453 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6454 printf("%s%s",
6455 hadFlag ? "|" : "",
6456 flag_names[flagIndex]);
6457 hadFlag = True;
6461 /* output synonyms */
6462 hadSyn = False;
6463 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6464 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6465 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6466 parm_table[parmIndex2].label);
6467 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6468 if (!hadSyn) {
6469 printf(" (synonyms: ");
6470 hadSyn = True;
6471 } else {
6472 printf(", ");
6474 printf("%s%s", parm_table[parmIndex2].label,
6475 inverse ? "[i]" : "");
6478 if (hadSyn) {
6479 printf(")");
6482 printf("\n");
6485 /***************************************************************************
6486 Show all parameter's name, type, [values,] and flags.
6487 ***************************************************************************/
6489 void show_parameter_list(void)
6491 int classIndex, parmIndex;
6492 const char *section_names[] = { "local", "global", NULL};
6494 for (classIndex=0; section_names[classIndex]; classIndex++) {
6495 printf("[%s]\n", section_names[classIndex]);
6496 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6497 if (parm_table[parmIndex].p_class == classIndex) {
6498 show_parameter(parmIndex);
6504 /***************************************************************************
6505 Check if a given string correctly represents a boolean value.
6506 ***************************************************************************/
6508 bool lp_string_is_valid_boolean(const char *parm_value)
6510 return set_boolean(parm_value, NULL);
6513 /***************************************************************************
6514 Get the standard string representation of a boolean value ("yes" or "no")
6515 ***************************************************************************/
6517 static const char *get_boolean(bool bool_value)
6519 static const char *yes_str = "yes";
6520 static const char *no_str = "no";
6522 return (bool_value ? yes_str : no_str);
6525 /***************************************************************************
6526 Provide the string of the negated boolean value associated to the boolean
6527 given as a string. Returns False if the passed string does not correctly
6528 represent a boolean.
6529 ***************************************************************************/
6531 bool lp_invert_boolean(const char *str, const char **inverse_str)
6533 bool val;
6535 if (!set_boolean(str, &val)) {
6536 return False;
6539 *inverse_str = get_boolean(!val);
6540 return True;
6543 /***************************************************************************
6544 Provide the canonical string representation of a boolean value given
6545 as a string. Return True on success, False if the string given does
6546 not correctly represent a boolean.
6547 ***************************************************************************/
6549 bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6551 bool val;
6553 if (!set_boolean(str, &val)) {
6554 return False;
6557 *canon_str = get_boolean(val);
6558 return True;
6561 /***************************************************************************
6562 Find a service by name. Otherwise works like get_service.
6563 ***************************************************************************/
6565 static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6567 int iService = -1;
6568 char *canon_name;
6569 TDB_DATA data;
6571 if (ServiceHash == NULL) {
6572 return -1;
6575 canon_name = canonicalize_servicename(pszServiceName);
6577 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6579 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6580 iService = *(int *)data.dptr;
6583 TALLOC_FREE(canon_name);
6585 if ((iService != -1) && (LP_SNUM_OK(iService))
6586 && (pserviceDest != NULL)) {
6587 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6590 return (iService);
6593 /***************************************************************************
6594 Copy a service structure to another.
6595 If pcopymapDest is NULL then copy all fields
6596 ***************************************************************************/
6599 * Add a parametric option to a param_opt_struct,
6600 * replacing old value, if already present.
6602 static void set_param_opt(struct param_opt_struct **opt_list,
6603 const char *opt_name,
6604 const char *opt_value)
6606 struct param_opt_struct *new_opt, *opt;
6607 bool not_added;
6609 if (opt_list == NULL) {
6610 return;
6613 opt = *opt_list;
6614 not_added = true;
6616 /* Traverse destination */
6617 while (opt) {
6618 /* If we already have same option, override it */
6619 if (strwicmp(opt->key, opt_name) == 0) {
6620 string_free(&opt->value);
6621 TALLOC_FREE(opt->list);
6622 opt->value = SMB_STRDUP(opt_value);
6623 not_added = false;
6624 break;
6626 opt = opt->next;
6628 if (not_added) {
6629 new_opt = SMB_XMALLOC_P(struct param_opt_struct);
6630 new_opt->key = SMB_STRDUP(opt_name);
6631 new_opt->value = SMB_STRDUP(opt_value);
6632 new_opt->list = NULL;
6633 DLIST_ADD(*opt_list, new_opt);
6637 static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6638 struct bitmap *pcopymapDest)
6640 int i;
6641 bool bcopyall = (pcopymapDest == NULL);
6642 struct param_opt_struct *data;
6644 for (i = 0; parm_table[i].label; i++)
6645 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6646 (bcopyall || bitmap_query(pcopymapDest,i))) {
6647 void *def_ptr = parm_table[i].ptr;
6648 void *src_ptr =
6649 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6650 &sDefault);
6651 void *dest_ptr =
6652 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6653 &sDefault);
6655 switch (parm_table[i].type) {
6656 case P_BOOL:
6657 case P_BOOLREV:
6658 *(bool *)dest_ptr = *(bool *)src_ptr;
6659 break;
6661 case P_INTEGER:
6662 case P_ENUM:
6663 case P_OCTAL:
6664 *(int *)dest_ptr = *(int *)src_ptr;
6665 break;
6667 case P_CHAR:
6668 *(char *)dest_ptr = *(char *)src_ptr;
6669 break;
6671 case P_STRING:
6672 string_set((char **)dest_ptr,
6673 *(char **)src_ptr);
6674 break;
6676 case P_USTRING:
6677 string_set((char **)dest_ptr,
6678 *(char **)src_ptr);
6679 strupper_m(*(char **)dest_ptr);
6680 break;
6681 case P_LIST:
6682 TALLOC_FREE(*((char ***)dest_ptr));
6683 *((char ***)dest_ptr) = str_list_copy(NULL,
6684 *(const char ***)src_ptr);
6685 break;
6686 default:
6687 break;
6691 if (bcopyall) {
6692 init_copymap(pserviceDest);
6693 if (pserviceSource->copymap)
6694 bitmap_copy(pserviceDest->copymap,
6695 pserviceSource->copymap);
6698 data = pserviceSource->param_opt;
6699 while (data) {
6700 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
6701 data = data->next;
6705 /***************************************************************************
6706 Check a service for consistency. Return False if the service is in any way
6707 incomplete or faulty, else True.
6708 ***************************************************************************/
6710 bool service_ok(int iService)
6712 bool bRetval;
6714 bRetval = True;
6715 if (ServicePtrs[iService]->szService[0] == '\0') {
6716 DEBUG(0, ("The following message indicates an internal error:\n"));
6717 DEBUG(0, ("No service name in service entry.\n"));
6718 bRetval = False;
6721 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6722 /* I can't see why you'd want a non-printable printer service... */
6723 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6724 if (!ServicePtrs[iService]->bPrint_ok) {
6725 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6726 ServicePtrs[iService]->szService));
6727 ServicePtrs[iService]->bPrint_ok = True;
6729 /* [printers] service must also be non-browsable. */
6730 if (ServicePtrs[iService]->bBrowseable)
6731 ServicePtrs[iService]->bBrowseable = False;
6734 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6735 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6736 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6738 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6739 ServicePtrs[iService]->szService));
6740 ServicePtrs[iService]->bAvailable = False;
6743 /* If a service is flagged unavailable, log the fact at level 1. */
6744 if (!ServicePtrs[iService]->bAvailable)
6745 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6746 ServicePtrs[iService]->szService));
6748 return (bRetval);
6751 static struct smbconf_ctx *lp_smbconf_ctx(void)
6753 WERROR werr;
6754 static struct smbconf_ctx *conf_ctx = NULL;
6756 if (conf_ctx == NULL) {
6757 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6758 if (!W_ERROR_IS_OK(werr)) {
6759 DEBUG(1, ("error initializing registry configuration: "
6760 "%s\n", win_errstr(werr)));
6761 conf_ctx = NULL;
6765 return conf_ctx;
6768 static bool process_smbconf_service(struct smbconf_service *service)
6770 uint32_t count;
6771 bool ret;
6773 if (service == NULL) {
6774 return false;
6777 ret = do_section(service->name, NULL);
6778 if (ret != true) {
6779 return false;
6781 for (count = 0; count < service->num_params; count++) {
6782 ret = do_parameter(service->param_names[count],
6783 service->param_values[count],
6784 NULL);
6785 if (ret != true) {
6786 return false;
6789 if (iServiceIndex >= 0) {
6790 return service_ok(iServiceIndex);
6792 return true;
6796 * load a service from registry and activate it
6798 bool process_registry_service(const char *service_name)
6800 WERROR werr;
6801 struct smbconf_service *service = NULL;
6802 TALLOC_CTX *mem_ctx = talloc_stackframe();
6803 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6804 bool ret = false;
6806 if (conf_ctx == NULL) {
6807 goto done;
6810 DEBUG(5, ("process_registry_service: service name %s\n", service_name));
6812 if (!smbconf_share_exists(conf_ctx, service_name)) {
6814 * Registry does not contain data for this service (yet),
6815 * but make sure lp_load doesn't return false.
6817 ret = true;
6818 goto done;
6821 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
6822 if (!W_ERROR_IS_OK(werr)) {
6823 goto done;
6826 ret = process_smbconf_service(service);
6827 if (!ret) {
6828 goto done;
6831 /* store the csn */
6832 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6834 done:
6835 TALLOC_FREE(mem_ctx);
6836 return ret;
6840 * process_registry_globals
6842 static bool process_registry_globals(void)
6844 bool ret;
6846 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6848 ret = do_parameter("registry shares", "yes", NULL);
6849 if (!ret) {
6850 return ret;
6853 return process_registry_service(GLOBAL_NAME);
6856 bool process_registry_shares(void)
6858 WERROR werr;
6859 uint32_t count;
6860 struct smbconf_service **service = NULL;
6861 uint32_t num_shares = 0;
6862 TALLOC_CTX *mem_ctx = talloc_stackframe();
6863 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6864 bool ret = false;
6866 if (conf_ctx == NULL) {
6867 goto done;
6870 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6871 if (!W_ERROR_IS_OK(werr)) {
6872 goto done;
6875 ret = true;
6877 for (count = 0; count < num_shares; count++) {
6878 if (strequal(service[count]->name, GLOBAL_NAME)) {
6879 continue;
6881 ret = process_smbconf_service(service[count]);
6882 if (!ret) {
6883 goto done;
6887 /* store the csn */
6888 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6890 done:
6891 TALLOC_FREE(mem_ctx);
6892 return ret;
6895 #define MAX_INCLUDE_DEPTH 100
6897 static uint8_t include_depth;
6899 static struct file_lists {
6900 struct file_lists *next;
6901 char *name;
6902 char *subfname;
6903 time_t modtime;
6904 } *file_lists = NULL;
6906 /*******************************************************************
6907 Keep a linked list of all config files so we know when one has changed
6908 it's date and needs to be reloaded.
6909 ********************************************************************/
6911 static void add_to_file_list(const char *fname, const char *subfname)
6913 struct file_lists *f = file_lists;
6915 while (f) {
6916 if (f->name && !strcmp(f->name, fname))
6917 break;
6918 f = f->next;
6921 if (!f) {
6922 f = SMB_MALLOC_P(struct file_lists);
6923 if (!f)
6924 return;
6925 f->next = file_lists;
6926 f->name = SMB_STRDUP(fname);
6927 if (!f->name) {
6928 SAFE_FREE(f);
6929 return;
6931 f->subfname = SMB_STRDUP(subfname);
6932 if (!f->subfname) {
6933 SAFE_FREE(f);
6934 return;
6936 file_lists = f;
6937 f->modtime = file_modtime(subfname);
6938 } else {
6939 time_t t = file_modtime(subfname);
6940 if (t)
6941 f->modtime = t;
6946 * Free the file lists
6948 static void free_file_list(void)
6950 struct file_lists *f;
6951 struct file_lists *next;
6953 f = file_lists;
6954 while( f ) {
6955 next = f->next;
6956 SAFE_FREE( f->name );
6957 SAFE_FREE( f->subfname );
6958 SAFE_FREE( f );
6959 f = next;
6961 file_lists = NULL;
6966 * Utility function for outsiders to check if we're running on registry.
6968 bool lp_config_backend_is_registry(void)
6970 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6974 * Utility function to check if the config backend is FILE.
6976 bool lp_config_backend_is_file(void)
6978 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6981 /*******************************************************************
6982 Check if a config file has changed date.
6983 ********************************************************************/
6985 bool lp_file_list_changed(void)
6987 struct file_lists *f = file_lists;
6989 DEBUG(6, ("lp_file_list_changed()\n"));
6991 while (f) {
6992 char *n2 = NULL;
6993 time_t mod_time;
6995 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6996 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6998 if (conf_ctx == NULL) {
6999 return false;
7001 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
7002 NULL))
7004 DEBUGADD(6, ("registry config changed\n"));
7005 return true;
7007 } else {
7008 n2 = alloc_sub_basic(get_current_username(),
7009 current_user_info.domain,
7010 f->name);
7011 if (!n2) {
7012 return false;
7014 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
7015 f->name, n2, ctime(&f->modtime)));
7017 mod_time = file_modtime(n2);
7019 if (mod_time &&
7020 ((f->modtime != mod_time) ||
7021 (f->subfname == NULL) ||
7022 (strcmp(n2, f->subfname) != 0)))
7024 DEBUGADD(6,
7025 ("file %s modified: %s\n", n2,
7026 ctime(&mod_time)));
7027 f->modtime = mod_time;
7028 SAFE_FREE(f->subfname);
7029 f->subfname = n2; /* Passing ownership of
7030 return from alloc_sub_basic
7031 above. */
7032 return true;
7034 SAFE_FREE(n2);
7036 f = f->next;
7038 return (False);
7042 /***************************************************************************
7043 Run standard_sub_basic on netbios name... needed because global_myname
7044 is not accessed through any lp_ macro.
7045 Note: We must *NOT* use string_set() here as ptr points to global_myname.
7046 ***************************************************************************/
7048 static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
7050 bool ret;
7051 char *netbios_name = alloc_sub_basic(get_current_username(),
7052 current_user_info.domain,
7053 pszParmValue);
7055 ret = set_global_myname(netbios_name);
7056 SAFE_FREE(netbios_name);
7057 string_set(&Globals.szNetbiosName,global_myname());
7059 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
7060 global_myname()));
7062 return ret;
7065 static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
7067 if (strcmp(*ptr, pszParmValue) != 0) {
7068 string_set(ptr, pszParmValue);
7069 init_iconv();
7071 return True;
7076 static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
7078 bool ret;
7080 ret = set_global_myworkgroup(pszParmValue);
7081 string_set(&Globals.szWorkgroup,lp_workgroup());
7083 return ret;
7086 static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
7088 bool ret;
7090 ret = set_global_scope(pszParmValue);
7091 string_set(&Globals.szNetbiosScope,global_scope());
7093 return ret;
7096 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
7098 TALLOC_FREE(Globals.szNetbiosAliases);
7099 Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
7100 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
7103 /***************************************************************************
7104 Handle the include operation.
7105 ***************************************************************************/
7106 static bool bAllowIncludeRegistry = true;
7108 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
7110 char *fname;
7112 if (include_depth >= MAX_INCLUDE_DEPTH) {
7113 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
7114 include_depth));
7115 return false;
7118 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
7119 if (!bAllowIncludeRegistry) {
7120 return true;
7122 if (bInGlobalSection) {
7123 bool ret;
7124 include_depth++;
7125 ret = process_registry_globals();
7126 include_depth--;
7127 return ret;
7128 } else {
7129 DEBUG(1, ("\"include = registry\" only effective "
7130 "in %s section\n", GLOBAL_NAME));
7131 return false;
7135 fname = alloc_sub_basic(get_current_username(),
7136 current_user_info.domain,
7137 pszParmValue);
7139 add_to_file_list(pszParmValue, fname);
7141 string_set(ptr, fname);
7143 if (file_exist(fname)) {
7144 bool ret;
7145 include_depth++;
7146 ret = pm_process(fname, do_section, do_parameter, NULL);
7147 include_depth--;
7148 SAFE_FREE(fname);
7149 return ret;
7152 DEBUG(2, ("Can't find include file %s\n", fname));
7153 SAFE_FREE(fname);
7154 return true;
7157 /***************************************************************************
7158 Handle the interpretation of the copy parameter.
7159 ***************************************************************************/
7161 static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
7163 bool bRetval;
7164 int iTemp;
7165 struct service serviceTemp;
7167 string_set(ptr, pszParmValue);
7169 init_service(&serviceTemp);
7171 bRetval = False;
7173 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
7175 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
7176 if (iTemp == iServiceIndex) {
7177 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
7178 } else {
7179 copy_service(ServicePtrs[iServiceIndex],
7180 &serviceTemp,
7181 ServicePtrs[iServiceIndex]->copymap);
7182 bRetval = True;
7184 } else {
7185 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7186 bRetval = False;
7189 free_service(&serviceTemp);
7190 return (bRetval);
7193 static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7195 Globals.ldap_debug_level = lp_int(pszParmValue);
7196 init_ldap_debugging();
7197 return true;
7200 /***************************************************************************
7201 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7202 parameters is:
7204 [global]
7206 idmap uid = 1000-1999
7207 idmap gid = 700-899
7209 We only do simple parsing checks here. The strings are parsed into useful
7210 structures in the idmap daemon code.
7212 ***************************************************************************/
7214 /* Some lp_ routines to return idmap [ug]id information */
7216 static uid_t idmap_uid_low, idmap_uid_high;
7217 static gid_t idmap_gid_low, idmap_gid_high;
7219 bool lp_idmap_uid(uid_t *low, uid_t *high)
7221 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7222 return False;
7224 if (low)
7225 *low = idmap_uid_low;
7227 if (high)
7228 *high = idmap_uid_high;
7230 return True;
7233 bool lp_idmap_gid(gid_t *low, gid_t *high)
7235 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7236 return False;
7238 if (low)
7239 *low = idmap_gid_low;
7241 if (high)
7242 *high = idmap_gid_high;
7244 return True;
7247 /* Do some simple checks on "idmap [ug]id" parameter values */
7249 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7251 uint32 low, high;
7253 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7254 return False;
7256 /* Parse OK */
7258 string_set(ptr, pszParmValue);
7260 idmap_uid_low = low;
7261 idmap_uid_high = high;
7263 return True;
7266 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7268 uint32 low, high;
7270 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7271 return False;
7273 /* Parse OK */
7275 string_set(ptr, pszParmValue);
7277 idmap_gid_low = low;
7278 idmap_gid_high = high;
7280 return True;
7283 /***************************************************************************
7284 Handle the DEBUG level list.
7285 ***************************************************************************/
7287 static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7289 string_set(ptr, pszParmValueIn);
7290 return debug_parse_levels(pszParmValueIn);
7293 /***************************************************************************
7294 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7295 ***************************************************************************/
7297 static const char *append_ldap_suffix( const char *str )
7299 const char *suffix_string;
7302 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7303 Globals.szLdapSuffix );
7304 if ( !suffix_string ) {
7305 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7306 return "";
7309 return suffix_string;
7312 const char *lp_ldap_machine_suffix(void)
7314 if (Globals.szLdapMachineSuffix[0])
7315 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7317 return lp_string(Globals.szLdapSuffix);
7320 const char *lp_ldap_user_suffix(void)
7322 if (Globals.szLdapUserSuffix[0])
7323 return append_ldap_suffix(Globals.szLdapUserSuffix);
7325 return lp_string(Globals.szLdapSuffix);
7328 const char *lp_ldap_group_suffix(void)
7330 if (Globals.szLdapGroupSuffix[0])
7331 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7333 return lp_string(Globals.szLdapSuffix);
7336 const char *lp_ldap_idmap_suffix(void)
7338 if (Globals.szLdapIdmapSuffix[0])
7339 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7341 return lp_string(Globals.szLdapSuffix);
7344 /****************************************************************************
7345 set the value for a P_ENUM
7346 ***************************************************************************/
7348 static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7349 int *ptr )
7351 int i;
7353 for (i = 0; parm->enum_list[i].name; i++) {
7354 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7355 *ptr = parm->enum_list[i].value;
7356 return;
7359 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7360 pszParmValue, parm->label));
7363 /***************************************************************************
7364 ***************************************************************************/
7366 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7368 static int parm_num = -1;
7369 struct service *s;
7371 if ( parm_num == -1 )
7372 parm_num = map_parameter( "printing" );
7374 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7376 if ( snum < 0 )
7377 s = &sDefault;
7378 else
7379 s = ServicePtrs[snum];
7381 init_printer_values( s );
7383 return True;
7387 /***************************************************************************
7388 Initialise a copymap.
7389 ***************************************************************************/
7391 static void init_copymap(struct service *pservice)
7393 int i;
7394 if (pservice->copymap) {
7395 bitmap_free(pservice->copymap);
7397 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7398 if (!pservice->copymap)
7399 DEBUG(0,
7400 ("Couldn't allocate copymap!! (size %d)\n",
7401 (int)NUMPARAMETERS));
7402 else
7403 for (i = 0; i < NUMPARAMETERS; i++)
7404 bitmap_set(pservice->copymap, i);
7407 /***************************************************************************
7408 Return the local pointer to a parameter given a service struct and the
7409 pointer into the default structure.
7410 ***************************************************************************/
7412 static void *lp_local_ptr(struct service *service, void *ptr)
7414 return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
7417 /***************************************************************************
7418 Return the local pointer to a parameter given the service number and the
7419 pointer into the default structure.
7420 ***************************************************************************/
7422 void *lp_local_ptr_by_snum(int snum, void *ptr)
7424 return lp_local_ptr(ServicePtrs[snum], ptr);
7427 /***************************************************************************
7428 Process a parameter for a particular service number. If snum < 0
7429 then assume we are in the globals.
7430 ***************************************************************************/
7432 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7434 int parmnum, i;
7435 void *parm_ptr = NULL; /* where we are going to store the result */
7436 void *def_ptr = NULL;
7437 struct param_opt_struct **opt_list;
7439 parmnum = map_parameter(pszParmName);
7441 if (parmnum < 0) {
7442 if (strchr(pszParmName, ':') == NULL) {
7443 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7444 pszParmName));
7445 return (True);
7449 * We've got a parametric option
7452 opt_list = (snum < 0)
7453 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
7454 set_param_opt(opt_list, pszParmName, pszParmValue);
7456 return (True);
7459 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7460 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7461 pszParmName));
7464 def_ptr = parm_table[parmnum].ptr;
7466 /* we might point at a service, the default service or a global */
7467 if (snum < 0) {
7468 parm_ptr = def_ptr;
7469 } else {
7470 if (parm_table[parmnum].p_class == P_GLOBAL) {
7471 DEBUG(0,
7472 ("Global parameter %s found in service section!\n",
7473 pszParmName));
7474 return (True);
7476 parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
7479 if (snum >= 0) {
7480 if (!ServicePtrs[snum]->copymap)
7481 init_copymap(ServicePtrs[snum]);
7483 /* this handles the aliases - set the copymap for other entries with
7484 the same data pointer */
7485 for (i = 0; parm_table[i].label; i++)
7486 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7487 bitmap_clear(ServicePtrs[snum]->copymap, i);
7490 /* if it is a special case then go ahead */
7491 if (parm_table[parmnum].special) {
7492 return parm_table[parmnum].special(snum, pszParmValue,
7493 (char **)parm_ptr);
7496 /* now switch on the type of variable it is */
7497 switch (parm_table[parmnum].type)
7499 case P_BOOL:
7500 *(bool *)parm_ptr = lp_bool(pszParmValue);
7501 break;
7503 case P_BOOLREV:
7504 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7505 break;
7507 case P_INTEGER:
7508 *(int *)parm_ptr = lp_int(pszParmValue);
7509 break;
7511 case P_CHAR:
7512 *(char *)parm_ptr = *pszParmValue;
7513 break;
7515 case P_OCTAL:
7516 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7517 if ( i != 1 ) {
7518 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7520 break;
7522 case P_LIST:
7523 TALLOC_FREE(*((char ***)parm_ptr));
7524 *(char ***)parm_ptr = str_list_make_v3(
7525 talloc_autofree_context(), pszParmValue, NULL);
7526 break;
7528 case P_STRING:
7529 string_set((char **)parm_ptr, pszParmValue);
7530 break;
7532 case P_USTRING:
7533 string_set((char **)parm_ptr, pszParmValue);
7534 strupper_m(*(char **)parm_ptr);
7535 break;
7537 case P_ENUM:
7538 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7539 break;
7540 case P_SEP:
7541 break;
7544 return (True);
7547 /***************************************************************************
7548 Process a parameter.
7549 ***************************************************************************/
7551 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7552 void *userdata)
7554 if (!bInGlobalSection && bGlobalOnly)
7555 return (True);
7557 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7559 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7560 pszParmName, pszParmValue));
7563 /***************************************************************************
7564 Print a parameter of the specified type.
7565 ***************************************************************************/
7567 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7569 int i;
7570 switch (p->type)
7572 case P_ENUM:
7573 for (i = 0; p->enum_list[i].name; i++) {
7574 if (*(int *)ptr == p->enum_list[i].value) {
7575 fprintf(f, "%s",
7576 p->enum_list[i].name);
7577 break;
7580 break;
7582 case P_BOOL:
7583 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7584 break;
7586 case P_BOOLREV:
7587 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7588 break;
7590 case P_INTEGER:
7591 fprintf(f, "%d", *(int *)ptr);
7592 break;
7594 case P_CHAR:
7595 fprintf(f, "%c", *(char *)ptr);
7596 break;
7598 case P_OCTAL: {
7599 char *o = octal_string(*(int *)ptr);
7600 fprintf(f, "%s", o);
7601 TALLOC_FREE(o);
7602 break;
7605 case P_LIST:
7606 if ((char ***)ptr && *(char ***)ptr) {
7607 char **list = *(char ***)ptr;
7608 for (; *list; list++) {
7609 /* surround strings with whitespace in double quotes */
7610 if ( strchr_m( *list, ' ' ) )
7611 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7612 else
7613 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7616 break;
7618 case P_STRING:
7619 case P_USTRING:
7620 if (*(char **)ptr) {
7621 fprintf(f, "%s", *(char **)ptr);
7623 break;
7624 case P_SEP:
7625 break;
7629 /***************************************************************************
7630 Check if two parameters are equal.
7631 ***************************************************************************/
7633 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7635 switch (type) {
7636 case P_BOOL:
7637 case P_BOOLREV:
7638 return (*((bool *)ptr1) == *((bool *)ptr2));
7640 case P_INTEGER:
7641 case P_ENUM:
7642 case P_OCTAL:
7643 return (*((int *)ptr1) == *((int *)ptr2));
7645 case P_CHAR:
7646 return (*((char *)ptr1) == *((char *)ptr2));
7648 case P_LIST:
7649 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
7651 case P_STRING:
7652 case P_USTRING:
7654 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7655 if (p1 && !*p1)
7656 p1 = NULL;
7657 if (p2 && !*p2)
7658 p2 = NULL;
7659 return (p1 == p2 || strequal(p1, p2));
7661 case P_SEP:
7662 break;
7664 return (False);
7667 /***************************************************************************
7668 Initialize any local varients in the sDefault table.
7669 ***************************************************************************/
7671 void init_locals(void)
7673 /* None as yet. */
7676 /***************************************************************************
7677 Process a new section (service). At this stage all sections are services.
7678 Later we'll have special sections that permit server parameters to be set.
7679 Returns True on success, False on failure.
7680 ***************************************************************************/
7682 static bool do_section(const char *pszSectionName, void *userdata)
7684 bool bRetval;
7685 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7686 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7687 bRetval = False;
7689 /* if we were in a global section then do the local inits */
7690 if (bInGlobalSection && !isglobal)
7691 init_locals();
7693 /* if we've just struck a global section, note the fact. */
7694 bInGlobalSection = isglobal;
7696 /* check for multiple global sections */
7697 if (bInGlobalSection) {
7698 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7699 return (True);
7702 if (!bInGlobalSection && bGlobalOnly)
7703 return (True);
7705 /* if we have a current service, tidy it up before moving on */
7706 bRetval = True;
7708 if (iServiceIndex >= 0)
7709 bRetval = service_ok(iServiceIndex);
7711 /* if all is still well, move to the next record in the services array */
7712 if (bRetval) {
7713 /* We put this here to avoid an odd message order if messages are */
7714 /* issued by the post-processing of a previous section. */
7715 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7717 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7718 < 0) {
7719 DEBUG(0, ("Failed to add a new service\n"));
7720 return (False);
7724 return (bRetval);
7728 /***************************************************************************
7729 Determine if a partcular base parameter is currentl set to the default value.
7730 ***************************************************************************/
7732 static bool is_default(int i)
7734 if (!defaults_saved)
7735 return False;
7736 switch (parm_table[i].type) {
7737 case P_LIST:
7738 return str_list_equal((const char **)parm_table[i].def.lvalue,
7739 *(const char ***)parm_table[i].ptr);
7740 case P_STRING:
7741 case P_USTRING:
7742 return strequal(parm_table[i].def.svalue,
7743 *(char **)parm_table[i].ptr);
7744 case P_BOOL:
7745 case P_BOOLREV:
7746 return parm_table[i].def.bvalue ==
7747 *(bool *)parm_table[i].ptr;
7748 case P_CHAR:
7749 return parm_table[i].def.cvalue ==
7750 *(char *)parm_table[i].ptr;
7751 case P_INTEGER:
7752 case P_OCTAL:
7753 case P_ENUM:
7754 return parm_table[i].def.ivalue ==
7755 *(int *)parm_table[i].ptr;
7756 case P_SEP:
7757 break;
7759 return False;
7762 /***************************************************************************
7763 Display the contents of the global structure.
7764 ***************************************************************************/
7766 static void dump_globals(FILE *f)
7768 int i;
7769 struct param_opt_struct *data;
7771 fprintf(f, "[global]\n");
7773 for (i = 0; parm_table[i].label; i++)
7774 if (parm_table[i].p_class == P_GLOBAL &&
7775 parm_table[i].ptr &&
7776 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7777 if (defaults_saved && is_default(i))
7778 continue;
7779 fprintf(f, "\t%s = ", parm_table[i].label);
7780 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7781 fprintf(f, "\n");
7783 if (Globals.param_opt != NULL) {
7784 data = Globals.param_opt;
7785 while(data) {
7786 fprintf(f, "\t%s = %s\n", data->key, data->value);
7787 data = data->next;
7793 /***************************************************************************
7794 Return True if a local parameter is currently set to the global default.
7795 ***************************************************************************/
7797 bool lp_is_default(int snum, struct parm_struct *parm)
7799 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7801 return equal_parameter(parm->type,
7802 ((char *)ServicePtrs[snum]) + pdiff,
7803 ((char *)&sDefault) + pdiff);
7806 /***************************************************************************
7807 Display the contents of a single services record.
7808 ***************************************************************************/
7810 static void dump_a_service(struct service *pService, FILE * f)
7812 int i;
7813 struct param_opt_struct *data;
7815 if (pService != &sDefault)
7816 fprintf(f, "[%s]\n", pService->szService);
7818 for (i = 0; parm_table[i].label; i++) {
7820 if (parm_table[i].p_class == P_LOCAL &&
7821 parm_table[i].ptr &&
7822 (*parm_table[i].label != '-') &&
7823 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7826 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7828 if (pService == &sDefault) {
7829 if (defaults_saved && is_default(i))
7830 continue;
7831 } else {
7832 if (equal_parameter(parm_table[i].type,
7833 ((char *)pService) +
7834 pdiff,
7835 ((char *)&sDefault) +
7836 pdiff))
7837 continue;
7840 fprintf(f, "\t%s = ", parm_table[i].label);
7841 print_parameter(&parm_table[i],
7842 ((char *)pService) + pdiff, f);
7843 fprintf(f, "\n");
7847 if (pService->param_opt != NULL) {
7848 data = pService->param_opt;
7849 while(data) {
7850 fprintf(f, "\t%s = %s\n", data->key, data->value);
7851 data = data->next;
7856 /***************************************************************************
7857 Display the contents of a parameter of a single services record.
7858 ***************************************************************************/
7860 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7862 int i;
7863 bool result = False;
7864 parm_class p_class;
7865 unsigned flag = 0;
7866 fstring local_parm_name;
7867 char *parm_opt;
7868 const char *parm_opt_value;
7870 /* check for parametrical option */
7871 fstrcpy( local_parm_name, parm_name);
7872 parm_opt = strchr( local_parm_name, ':');
7874 if (parm_opt) {
7875 *parm_opt = '\0';
7876 parm_opt++;
7877 if (strlen(parm_opt)) {
7878 parm_opt_value = lp_parm_const_string( snum,
7879 local_parm_name, parm_opt, NULL);
7880 if (parm_opt_value) {
7881 printf( "%s\n", parm_opt_value);
7882 result = True;
7885 return result;
7888 /* check for a key and print the value */
7889 if (isGlobal) {
7890 p_class = P_GLOBAL;
7891 flag = FLAG_GLOBAL;
7892 } else
7893 p_class = P_LOCAL;
7895 for (i = 0; parm_table[i].label; i++) {
7896 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7897 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7898 parm_table[i].ptr &&
7899 (*parm_table[i].label != '-') &&
7900 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7902 void *ptr;
7904 if (isGlobal) {
7905 ptr = parm_table[i].ptr;
7906 } else {
7907 struct service *pService = ServicePtrs[snum];
7908 ptr = ((char *)pService) +
7909 PTR_DIFF(parm_table[i].ptr, &sDefault);
7912 print_parameter(&parm_table[i],
7913 ptr, f);
7914 fprintf(f, "\n");
7915 result = True;
7916 break;
7920 return result;
7923 /***************************************************************************
7924 Return info about the requested parameter (given as a string).
7925 Return NULL when the string is not a valid parameter name.
7926 ***************************************************************************/
7928 struct parm_struct *lp_get_parameter(const char *param_name)
7930 int num = map_parameter(param_name);
7932 if (num < 0) {
7933 return NULL;
7936 return &parm_table[num];
7939 /***************************************************************************
7940 Return info about the next parameter in a service.
7941 snum==GLOBAL_SECTION_SNUM gives the globals.
7942 Return NULL when out of parameters.
7943 ***************************************************************************/
7945 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7947 if (snum < 0) {
7948 /* do the globals */
7949 for (; parm_table[*i].label; (*i)++) {
7950 if (parm_table[*i].p_class == P_SEPARATOR)
7951 return &parm_table[(*i)++];
7953 if (!parm_table[*i].ptr
7954 || (*parm_table[*i].label == '-'))
7955 continue;
7957 if ((*i) > 0
7958 && (parm_table[*i].ptr ==
7959 parm_table[(*i) - 1].ptr))
7960 continue;
7962 if (is_default(*i) && !allparameters)
7963 continue;
7965 return &parm_table[(*i)++];
7967 } else {
7968 struct service *pService = ServicePtrs[snum];
7970 for (; parm_table[*i].label; (*i)++) {
7971 if (parm_table[*i].p_class == P_SEPARATOR)
7972 return &parm_table[(*i)++];
7974 if (parm_table[*i].p_class == P_LOCAL &&
7975 parm_table[*i].ptr &&
7976 (*parm_table[*i].label != '-') &&
7977 ((*i) == 0 ||
7978 (parm_table[*i].ptr !=
7979 parm_table[(*i) - 1].ptr)))
7981 int pdiff =
7982 PTR_DIFF(parm_table[*i].ptr,
7983 &sDefault);
7985 if (allparameters ||
7986 !equal_parameter(parm_table[*i].type,
7987 ((char *)pService) +
7988 pdiff,
7989 ((char *)&sDefault) +
7990 pdiff))
7992 return &parm_table[(*i)++];
7998 return NULL;
8002 #if 0
8003 /***************************************************************************
8004 Display the contents of a single copy structure.
8005 ***************************************************************************/
8006 static void dump_copy_map(bool *pcopymap)
8008 int i;
8009 if (!pcopymap)
8010 return;
8012 printf("\n\tNon-Copied parameters:\n");
8014 for (i = 0; parm_table[i].label; i++)
8015 if (parm_table[i].p_class == P_LOCAL &&
8016 parm_table[i].ptr && !pcopymap[i] &&
8017 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
8019 printf("\t\t%s\n", parm_table[i].label);
8022 #endif
8024 /***************************************************************************
8025 Return TRUE if the passed service number is within range.
8026 ***************************************************************************/
8028 bool lp_snum_ok(int iService)
8030 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
8033 /***************************************************************************
8034 Auto-load some home services.
8035 ***************************************************************************/
8037 static void lp_add_auto_services(char *str)
8039 char *s;
8040 char *p;
8041 int homes;
8042 char *saveptr;
8044 if (!str)
8045 return;
8047 s = SMB_STRDUP(str);
8048 if (!s)
8049 return;
8051 homes = lp_servicenumber(HOMES_NAME);
8053 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
8054 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
8055 char *home;
8057 if (lp_servicenumber(p) >= 0)
8058 continue;
8060 home = get_user_home_dir(talloc_tos(), p);
8062 if (home && homes >= 0)
8063 lp_add_home(p, homes, p, home);
8065 TALLOC_FREE(home);
8067 SAFE_FREE(s);
8070 /***************************************************************************
8071 Auto-load one printer.
8072 ***************************************************************************/
8074 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
8076 int printers = lp_servicenumber(PRINTERS_NAME);
8077 int i;
8079 if (lp_servicenumber(name) < 0) {
8080 lp_add_printer(name, printers);
8081 if ((i = lp_servicenumber(name)) >= 0) {
8082 string_set(&ServicePtrs[i]->comment, comment);
8083 ServicePtrs[i]->autoloaded = True;
8088 /***************************************************************************
8089 Have we loaded a services file yet?
8090 ***************************************************************************/
8092 bool lp_loaded(void)
8094 return (bLoaded);
8097 /***************************************************************************
8098 Unload unused services.
8099 ***************************************************************************/
8101 void lp_killunused(bool (*snumused) (int))
8103 int i;
8104 for (i = 0; i < iNumServices; i++) {
8105 if (!VALID(i))
8106 continue;
8108 /* don't kill autoloaded or usershare services */
8109 if ( ServicePtrs[i]->autoloaded ||
8110 ServicePtrs[i]->usershare == USERSHARE_VALID) {
8111 continue;
8114 if (!snumused || !snumused(i)) {
8115 free_service_byindex(i);
8121 * Kill all except autoloaded and usershare services - convenience wrapper
8123 void lp_kill_all_services(void)
8125 lp_killunused(NULL);
8128 /***************************************************************************
8129 Unload a service.
8130 ***************************************************************************/
8132 void lp_killservice(int iServiceIn)
8134 if (VALID(iServiceIn)) {
8135 free_service_byindex(iServiceIn);
8139 /***************************************************************************
8140 Save the curent values of all global and sDefault parameters into the
8141 defaults union. This allows swat and testparm to show only the
8142 changed (ie. non-default) parameters.
8143 ***************************************************************************/
8145 static void lp_save_defaults(void)
8147 int i;
8148 for (i = 0; parm_table[i].label; i++) {
8149 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
8150 continue;
8151 switch (parm_table[i].type) {
8152 case P_LIST:
8153 parm_table[i].def.lvalue = str_list_copy(
8154 NULL, *(const char ***)parm_table[i].ptr);
8155 break;
8156 case P_STRING:
8157 case P_USTRING:
8158 if (parm_table[i].ptr) {
8159 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8160 } else {
8161 parm_table[i].def.svalue = NULL;
8163 break;
8164 case P_BOOL:
8165 case P_BOOLREV:
8166 parm_table[i].def.bvalue =
8167 *(bool *)parm_table[i].ptr;
8168 break;
8169 case P_CHAR:
8170 parm_table[i].def.cvalue =
8171 *(char *)parm_table[i].ptr;
8172 break;
8173 case P_INTEGER:
8174 case P_OCTAL:
8175 case P_ENUM:
8176 parm_table[i].def.ivalue =
8177 *(int *)parm_table[i].ptr;
8178 break;
8179 case P_SEP:
8180 break;
8183 defaults_saved = True;
8186 /*******************************************************************
8187 Set the server type we will announce as via nmbd.
8188 ********************************************************************/
8190 static const struct srv_role_tab {
8191 uint32 role;
8192 const char *role_str;
8193 } srv_role_tab [] = {
8194 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8195 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8196 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8197 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8198 { 0, NULL }
8201 const char* server_role_str(uint32 role)
8203 int i = 0;
8204 for (i=0; srv_role_tab[i].role_str; i++) {
8205 if (role == srv_role_tab[i].role) {
8206 return srv_role_tab[i].role_str;
8209 return NULL;
8212 static void set_server_role(void)
8214 server_role = ROLE_STANDALONE;
8216 switch (lp_security()) {
8217 case SEC_SHARE:
8218 if (lp_domain_logons())
8219 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8220 break;
8221 case SEC_SERVER:
8222 if (lp_domain_logons())
8223 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8224 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8225 server_role = ROLE_STANDALONE;
8226 break;
8227 case SEC_DOMAIN:
8228 if (lp_domain_logons()) {
8229 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8230 server_role = ROLE_DOMAIN_BDC;
8231 break;
8233 server_role = ROLE_DOMAIN_MEMBER;
8234 break;
8235 case SEC_ADS:
8236 if (lp_domain_logons()) {
8237 server_role = ROLE_DOMAIN_PDC;
8238 break;
8240 server_role = ROLE_DOMAIN_MEMBER;
8241 break;
8242 case SEC_USER:
8243 if (lp_domain_logons()) {
8245 if (Globals.iDomainMaster) /* auto or yes */
8246 server_role = ROLE_DOMAIN_PDC;
8247 else
8248 server_role = ROLE_DOMAIN_BDC;
8250 break;
8251 default:
8252 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8253 break;
8256 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8259 /***********************************************************
8260 If we should send plaintext/LANMAN passwords in the clinet
8261 ************************************************************/
8263 static void set_allowed_client_auth(void)
8265 if (Globals.bClientNTLMv2Auth) {
8266 Globals.bClientLanManAuth = False;
8268 if (!Globals.bClientLanManAuth) {
8269 Globals.bClientPlaintextAuth = False;
8273 /***************************************************************************
8274 JRA.
8275 The following code allows smbd to read a user defined share file.
8276 Yes, this is my intent. Yes, I'm comfortable with that...
8278 THE FOLLOWING IS SECURITY CRITICAL CODE.
8280 It washes your clothes, it cleans your house, it guards you while you sleep...
8281 Do not f%^k with it....
8282 ***************************************************************************/
8284 #define MAX_USERSHARE_FILE_SIZE (10*1024)
8286 /***************************************************************************
8287 Check allowed stat state of a usershare file.
8288 Ensure we print out who is dicking with us so the admin can
8289 get their sorry ass fired.
8290 ***************************************************************************/
8292 static bool check_usershare_stat(const char *fname, SMB_STRUCT_STAT *psbuf)
8294 if (!S_ISREG(psbuf->st_mode)) {
8295 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8296 "not a regular file\n",
8297 fname, (unsigned int)psbuf->st_uid ));
8298 return False;
8301 /* Ensure this doesn't have the other write bit set. */
8302 if (psbuf->st_mode & S_IWOTH) {
8303 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8304 "public write. Refusing to allow as a usershare file.\n",
8305 fname, (unsigned int)psbuf->st_uid ));
8306 return False;
8309 /* Should be 10k or less. */
8310 if (psbuf->st_size > MAX_USERSHARE_FILE_SIZE) {
8311 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8312 "too large (%u) to be a user share file.\n",
8313 fname, (unsigned int)psbuf->st_uid,
8314 (unsigned int)psbuf->st_size ));
8315 return False;
8318 return True;
8321 /***************************************************************************
8322 Parse the contents of a usershare file.
8323 ***************************************************************************/
8325 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8326 SMB_STRUCT_STAT *psbuf,
8327 const char *servicename,
8328 int snum,
8329 char **lines,
8330 int numlines,
8331 char **pp_sharepath,
8332 char **pp_comment,
8333 SEC_DESC **ppsd,
8334 bool *pallow_guest)
8336 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8337 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8338 int us_vers;
8339 SMB_STRUCT_DIR *dp;
8340 SMB_STRUCT_STAT sbuf;
8341 char *sharepath = NULL;
8342 char *comment = NULL;
8344 *pp_sharepath = NULL;
8345 *pp_comment = NULL;
8347 *pallow_guest = False;
8349 if (numlines < 4) {
8350 return USERSHARE_MALFORMED_FILE;
8353 if (strcmp(lines[0], "#VERSION 1") == 0) {
8354 us_vers = 1;
8355 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8356 us_vers = 2;
8357 if (numlines < 5) {
8358 return USERSHARE_MALFORMED_FILE;
8360 } else {
8361 return USERSHARE_BAD_VERSION;
8364 if (strncmp(lines[1], "path=", 5) != 0) {
8365 return USERSHARE_MALFORMED_PATH;
8368 sharepath = talloc_strdup(ctx, &lines[1][5]);
8369 if (!sharepath) {
8370 return USERSHARE_POSIX_ERR;
8372 trim_string(sharepath, " ", " ");
8374 if (strncmp(lines[2], "comment=", 8) != 0) {
8375 return USERSHARE_MALFORMED_COMMENT_DEF;
8378 comment = talloc_strdup(ctx, &lines[2][8]);
8379 if (!comment) {
8380 return USERSHARE_POSIX_ERR;
8382 trim_string(comment, " ", " ");
8383 trim_char(comment, '"', '"');
8385 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8386 return USERSHARE_MALFORMED_ACL_DEF;
8389 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8390 return USERSHARE_ACL_ERR;
8393 if (us_vers == 2) {
8394 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8395 return USERSHARE_MALFORMED_ACL_DEF;
8397 if (lines[4][9] == 'y') {
8398 *pallow_guest = True;
8402 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8403 /* Path didn't change, no checks needed. */
8404 *pp_sharepath = sharepath;
8405 *pp_comment = comment;
8406 return USERSHARE_OK;
8409 /* The path *must* be absolute. */
8410 if (sharepath[0] != '/') {
8411 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8412 servicename, sharepath));
8413 return USERSHARE_PATH_NOT_ABSOLUTE;
8416 /* If there is a usershare prefix deny list ensure one of these paths
8417 doesn't match the start of the user given path. */
8418 if (prefixdenylist) {
8419 int i;
8420 for ( i=0; prefixdenylist[i]; i++ ) {
8421 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8422 servicename, i, prefixdenylist[i], sharepath ));
8423 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8424 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8425 "usershare prefix deny list entries.\n",
8426 servicename, sharepath));
8427 return USERSHARE_PATH_IS_DENIED;
8432 /* If there is a usershare prefix allow list ensure one of these paths
8433 does match the start of the user given path. */
8435 if (prefixallowlist) {
8436 int i;
8437 for ( i=0; prefixallowlist[i]; i++ ) {
8438 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8439 servicename, i, prefixallowlist[i], sharepath ));
8440 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8441 break;
8444 if (prefixallowlist[i] == NULL) {
8445 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8446 "usershare prefix allow list entries.\n",
8447 servicename, sharepath));
8448 return USERSHARE_PATH_NOT_ALLOWED;
8452 /* Ensure this is pointing to a directory. */
8453 dp = sys_opendir(sharepath);
8455 if (!dp) {
8456 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8457 servicename, sharepath));
8458 return USERSHARE_PATH_NOT_DIRECTORY;
8461 /* Ensure the owner of the usershare file has permission to share
8462 this directory. */
8464 if (sys_stat(sharepath, &sbuf) == -1) {
8465 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8466 servicename, sharepath, strerror(errno) ));
8467 sys_closedir(dp);
8468 return USERSHARE_POSIX_ERR;
8471 sys_closedir(dp);
8473 if (!S_ISDIR(sbuf.st_mode)) {
8474 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8475 servicename, sharepath ));
8476 return USERSHARE_PATH_NOT_DIRECTORY;
8479 /* Check if sharing is restricted to owner-only. */
8480 /* psbuf is the stat of the usershare definition file,
8481 sbuf is the stat of the target directory to be shared. */
8483 if (lp_usershare_owner_only()) {
8484 /* root can share anything. */
8485 if ((psbuf->st_uid != 0) && (sbuf.st_uid != psbuf->st_uid)) {
8486 return USERSHARE_PATH_NOT_ALLOWED;
8490 *pp_sharepath = sharepath;
8491 *pp_comment = comment;
8492 return USERSHARE_OK;
8495 /***************************************************************************
8496 Deal with a usershare file.
8497 Returns:
8498 >= 0 - snum
8499 -1 - Bad name, invalid contents.
8500 - service name already existed and not a usershare, problem
8501 with permissions to share directory etc.
8502 ***************************************************************************/
8504 static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8506 SMB_STRUCT_STAT sbuf;
8507 SMB_STRUCT_STAT lsbuf;
8508 char *fname = NULL;
8509 char *sharepath = NULL;
8510 char *comment = NULL;
8511 fstring service_name;
8512 char **lines = NULL;
8513 int numlines = 0;
8514 int fd = -1;
8515 int iService = -1;
8516 TALLOC_CTX *ctx = NULL;
8517 SEC_DESC *psd = NULL;
8518 bool guest_ok = False;
8520 /* Ensure share name doesn't contain invalid characters. */
8521 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8522 DEBUG(0,("process_usershare_file: share name %s contains "
8523 "invalid characters (any of %s)\n",
8524 file_name, INVALID_SHARENAME_CHARS ));
8525 return -1;
8528 fstrcpy(service_name, file_name);
8530 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8533 /* Minimize the race condition by doing an lstat before we
8534 open and fstat. Ensure this isn't a symlink link. */
8536 if (sys_lstat(fname, &lsbuf) != 0) {
8537 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8538 fname, strerror(errno) ));
8539 SAFE_FREE(fname);
8540 return -1;
8543 /* This must be a regular file, not a symlink, directory or
8544 other strange filetype. */
8545 if (!check_usershare_stat(fname, &lsbuf)) {
8546 SAFE_FREE(fname);
8547 return -1;
8551 char *canon_name = canonicalize_servicename(service_name);
8552 TDB_DATA data = dbwrap_fetch_bystring(
8553 ServiceHash, canon_name, canon_name);
8555 iService = -1;
8557 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8558 iService = *(int *)data.dptr;
8560 TALLOC_FREE(canon_name);
8563 if (iService != -1 && ServicePtrs[iService]->usershare_last_mod == lsbuf.st_mtime) {
8564 /* Nothing changed - Mark valid and return. */
8565 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8566 service_name ));
8567 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8568 SAFE_FREE(fname);
8569 return iService;
8572 /* Try and open the file read only - no symlinks allowed. */
8573 #ifdef O_NOFOLLOW
8574 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8575 #else
8576 fd = sys_open(fname, O_RDONLY, 0);
8577 #endif
8579 if (fd == -1) {
8580 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8581 fname, strerror(errno) ));
8582 SAFE_FREE(fname);
8583 return -1;
8586 /* Now fstat to be *SURE* it's a regular file. */
8587 if (sys_fstat(fd, &sbuf) != 0) {
8588 close(fd);
8589 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8590 fname, strerror(errno) ));
8591 SAFE_FREE(fname);
8592 return -1;
8595 /* Is it the same dev/inode as was lstated ? */
8596 if (lsbuf.st_dev != sbuf.st_dev || lsbuf.st_ino != sbuf.st_ino) {
8597 close(fd);
8598 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8599 "Symlink spoofing going on ?\n", fname ));
8600 SAFE_FREE(fname);
8601 return -1;
8604 /* This must be a regular file, not a symlink, directory or
8605 other strange filetype. */
8606 if (!check_usershare_stat(fname, &sbuf)) {
8607 SAFE_FREE(fname);
8608 return -1;
8611 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
8613 close(fd);
8614 if (lines == NULL) {
8615 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8616 fname, (unsigned int)sbuf.st_uid ));
8617 SAFE_FREE(fname);
8618 return -1;
8621 SAFE_FREE(fname);
8623 /* Should we allow printers to be shared... ? */
8624 ctx = talloc_init("usershare_sd_xctx");
8625 if (!ctx) {
8626 TALLOC_FREE(lines);
8627 return 1;
8630 if (parse_usershare_file(ctx, &sbuf, service_name,
8631 iService, lines, numlines, &sharepath,
8632 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8633 talloc_destroy(ctx);
8634 TALLOC_FREE(lines);
8635 return -1;
8638 TALLOC_FREE(lines);
8640 /* Everything ok - add the service possibly using a template. */
8641 if (iService < 0) {
8642 const struct service *sp = &sDefault;
8643 if (snum_template != -1) {
8644 sp = ServicePtrs[snum_template];
8647 if ((iService = add_a_service(sp, service_name)) < 0) {
8648 DEBUG(0, ("process_usershare_file: Failed to add "
8649 "new service %s\n", service_name));
8650 talloc_destroy(ctx);
8651 return -1;
8654 /* Read only is controlled by usershare ACL below. */
8655 ServicePtrs[iService]->bRead_only = False;
8658 /* Write the ACL of the new/modified share. */
8659 if (!set_share_security(service_name, psd)) {
8660 DEBUG(0, ("process_usershare_file: Failed to set share "
8661 "security for user share %s\n",
8662 service_name ));
8663 lp_remove_service(iService);
8664 talloc_destroy(ctx);
8665 return -1;
8668 /* If from a template it may be marked invalid. */
8669 ServicePtrs[iService]->valid = True;
8671 /* Set the service as a valid usershare. */
8672 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8674 /* Set guest access. */
8675 if (lp_usershare_allow_guests()) {
8676 ServicePtrs[iService]->bGuest_ok = guest_ok;
8679 /* And note when it was loaded. */
8680 ServicePtrs[iService]->usershare_last_mod = sbuf.st_mtime;
8681 string_set(&ServicePtrs[iService]->szPath, sharepath);
8682 string_set(&ServicePtrs[iService]->comment, comment);
8684 talloc_destroy(ctx);
8686 return iService;
8689 /***************************************************************************
8690 Checks if a usershare entry has been modified since last load.
8691 ***************************************************************************/
8693 static bool usershare_exists(int iService, time_t *last_mod)
8695 SMB_STRUCT_STAT lsbuf;
8696 const char *usersharepath = Globals.szUsersharePath;
8697 char *fname;
8699 if (asprintf(&fname, "%s/%s",
8700 usersharepath,
8701 ServicePtrs[iService]->szService) < 0) {
8702 return false;
8705 if (sys_lstat(fname, &lsbuf) != 0) {
8706 SAFE_FREE(fname);
8707 return false;
8710 if (!S_ISREG(lsbuf.st_mode)) {
8711 SAFE_FREE(fname);
8712 return false;
8715 SAFE_FREE(fname);
8716 *last_mod = lsbuf.st_mtime;
8717 return true;
8720 /***************************************************************************
8721 Load a usershare service by name. Returns a valid servicenumber or -1.
8722 ***************************************************************************/
8724 int load_usershare_service(const char *servicename)
8726 SMB_STRUCT_STAT sbuf;
8727 const char *usersharepath = Globals.szUsersharePath;
8728 int max_user_shares = Globals.iUsershareMaxShares;
8729 int snum_template = -1;
8731 if (*usersharepath == 0 || max_user_shares == 0) {
8732 return -1;
8735 if (sys_stat(usersharepath, &sbuf) != 0) {
8736 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8737 usersharepath, strerror(errno) ));
8738 return -1;
8741 if (!S_ISDIR(sbuf.st_mode)) {
8742 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8743 usersharepath ));
8744 return -1;
8748 * This directory must be owned by root, and have the 't' bit set.
8749 * It also must not be writable by "other".
8752 #ifdef S_ISVTX
8753 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8754 #else
8755 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8756 #endif
8757 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8758 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8759 usersharepath ));
8760 return -1;
8763 /* Ensure the template share exists if it's set. */
8764 if (Globals.szUsershareTemplateShare[0]) {
8765 /* We can't use lp_servicenumber here as we are recommending that
8766 template shares have -valid=False set. */
8767 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8768 if (ServicePtrs[snum_template]->szService &&
8769 strequal(ServicePtrs[snum_template]->szService,
8770 Globals.szUsershareTemplateShare)) {
8771 break;
8775 if (snum_template == -1) {
8776 DEBUG(0,("load_usershare_service: usershare template share %s "
8777 "does not exist.\n",
8778 Globals.szUsershareTemplateShare ));
8779 return -1;
8783 return process_usershare_file(usersharepath, servicename, snum_template);
8786 /***************************************************************************
8787 Load all user defined shares from the user share directory.
8788 We only do this if we're enumerating the share list.
8789 This is the function that can delete usershares that have
8790 been removed.
8791 ***************************************************************************/
8793 int load_usershare_shares(void)
8795 SMB_STRUCT_DIR *dp;
8796 SMB_STRUCT_STAT sbuf;
8797 SMB_STRUCT_DIRENT *de;
8798 int num_usershares = 0;
8799 int max_user_shares = Globals.iUsershareMaxShares;
8800 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8801 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8802 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8803 int iService;
8804 int snum_template = -1;
8805 const char *usersharepath = Globals.szUsersharePath;
8806 int ret = lp_numservices();
8808 if (max_user_shares == 0 || *usersharepath == '\0') {
8809 return lp_numservices();
8812 if (sys_stat(usersharepath, &sbuf) != 0) {
8813 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8814 usersharepath, strerror(errno) ));
8815 return ret;
8819 * This directory must be owned by root, and have the 't' bit set.
8820 * It also must not be writable by "other".
8823 #ifdef S_ISVTX
8824 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8825 #else
8826 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8827 #endif
8828 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8829 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8830 usersharepath ));
8831 return ret;
8834 /* Ensure the template share exists if it's set. */
8835 if (Globals.szUsershareTemplateShare[0]) {
8836 /* We can't use lp_servicenumber here as we are recommending that
8837 template shares have -valid=False set. */
8838 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8839 if (ServicePtrs[snum_template]->szService &&
8840 strequal(ServicePtrs[snum_template]->szService,
8841 Globals.szUsershareTemplateShare)) {
8842 break;
8846 if (snum_template == -1) {
8847 DEBUG(0,("load_usershare_shares: usershare template share %s "
8848 "does not exist.\n",
8849 Globals.szUsershareTemplateShare ));
8850 return ret;
8854 /* Mark all existing usershares as pending delete. */
8855 for (iService = iNumServices - 1; iService >= 0; iService--) {
8856 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8857 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8861 dp = sys_opendir(usersharepath);
8862 if (!dp) {
8863 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8864 usersharepath, strerror(errno) ));
8865 return ret;
8868 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8869 (de = sys_readdir(dp));
8870 num_dir_entries++ ) {
8871 int r;
8872 const char *n = de->d_name;
8874 /* Ignore . and .. */
8875 if (*n == '.') {
8876 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8877 continue;
8881 if (n[0] == ':') {
8882 /* Temporary file used when creating a share. */
8883 num_tmp_dir_entries++;
8886 /* Allow 20% tmp entries. */
8887 if (num_tmp_dir_entries > allowed_tmp_entries) {
8888 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8889 "in directory %s\n",
8890 num_tmp_dir_entries, usersharepath));
8891 break;
8894 r = process_usershare_file(usersharepath, n, snum_template);
8895 if (r == 0) {
8896 /* Update the services count. */
8897 num_usershares++;
8898 if (num_usershares >= max_user_shares) {
8899 DEBUG(0,("load_usershare_shares: max user shares reached "
8900 "on file %s in directory %s\n",
8901 n, usersharepath ));
8902 break;
8904 } else if (r == -1) {
8905 num_bad_dir_entries++;
8908 /* Allow 20% bad entries. */
8909 if (num_bad_dir_entries > allowed_bad_entries) {
8910 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8911 "in directory %s\n",
8912 num_bad_dir_entries, usersharepath));
8913 break;
8916 /* Allow 20% bad entries. */
8917 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8918 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8919 "in directory %s\n",
8920 num_dir_entries, usersharepath));
8921 break;
8925 sys_closedir(dp);
8927 /* Sweep through and delete any non-refreshed usershares that are
8928 not currently in use. */
8929 for (iService = iNumServices - 1; iService >= 0; iService--) {
8930 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8931 if (conn_snum_used(iService)) {
8932 continue;
8934 /* Remove from the share ACL db. */
8935 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8936 lp_servicename(iService) ));
8937 delete_share_security(lp_servicename(iService));
8938 free_service_byindex(iService);
8942 return lp_numservices();
8945 /********************************************************
8946 Destroy global resources allocated in this file
8947 ********************************************************/
8949 void gfree_loadparm(void)
8951 int i;
8953 free_file_list();
8955 /* Free resources allocated to services */
8957 for ( i = 0; i < iNumServices; i++ ) {
8958 if ( VALID(i) ) {
8959 free_service_byindex(i);
8963 SAFE_FREE( ServicePtrs );
8964 iNumServices = 0;
8966 /* Now release all resources allocated to global
8967 parameters and the default service */
8969 free_global_parameters();
8973 /***************************************************************************
8974 Allow client apps to specify that they are a client
8975 ***************************************************************************/
8976 void lp_set_in_client(bool b)
8978 in_client = b;
8982 /***************************************************************************
8983 Determine if we're running in a client app
8984 ***************************************************************************/
8985 bool lp_is_in_client(void)
8987 return in_client;
8990 /***************************************************************************
8991 Load the services array from the services file. Return True on success,
8992 False on failure.
8993 ***************************************************************************/
8995 bool lp_load_ex(const char *pszFname,
8996 bool global_only,
8997 bool save_defaults,
8998 bool add_ipc,
8999 bool initialize_globals,
9000 bool allow_include_registry,
9001 bool allow_registry_shares)
9003 char *n2 = NULL;
9004 bool bRetval;
9006 bRetval = False;
9008 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
9010 bInGlobalSection = True;
9011 bGlobalOnly = global_only;
9012 bAllowIncludeRegistry = allow_include_registry;
9014 init_globals(! initialize_globals);
9015 debug_init();
9017 free_file_list();
9019 if (save_defaults) {
9020 init_locals();
9021 lp_save_defaults();
9024 free_param_opts(&Globals.param_opt);
9026 /* We get sections first, so have to start 'behind' to make up */
9027 iServiceIndex = -1;
9029 if (lp_config_backend_is_file()) {
9030 n2 = alloc_sub_basic(get_current_username(),
9031 current_user_info.domain,
9032 pszFname);
9033 if (!n2) {
9034 smb_panic("lp_load_ex: out of memory");
9037 add_to_file_list(pszFname, n2);
9039 bRetval = pm_process(n2, do_section, do_parameter, NULL);
9040 SAFE_FREE(n2);
9042 /* finish up the last section */
9043 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
9044 if (bRetval) {
9045 if (iServiceIndex >= 0) {
9046 bRetval = service_ok(iServiceIndex);
9050 if (lp_config_backend_is_registry()) {
9051 /* config backend changed to registry in config file */
9053 * We need to use this extra global variable here to
9054 * survive restart: init_globals uses this as a default
9055 * for ConfigBackend. Otherwise, init_globals would
9056 * send us into an endless loop here.
9058 config_backend = CONFIG_BACKEND_REGISTRY;
9059 /* start over */
9060 DEBUG(1, ("lp_load_ex: changing to config backend "
9061 "registry\n"));
9062 init_globals(false);
9063 lp_kill_all_services();
9064 return lp_load_ex(pszFname, global_only, save_defaults,
9065 add_ipc, initialize_globals,
9066 allow_include_registry,
9067 allow_registry_shares);
9069 } else if (lp_config_backend_is_registry()) {
9070 bRetval = process_registry_globals();
9071 } else {
9072 DEBUG(0, ("Illegal config backend given: %d\n",
9073 lp_config_backend()));
9074 bRetval = false;
9077 if (bRetval && lp_registry_shares() && allow_registry_shares) {
9078 bRetval = process_registry_shares();
9081 lp_add_auto_services(lp_auto_services());
9083 if (add_ipc) {
9084 /* When 'restrict anonymous = 2' guest connections to ipc$
9085 are denied */
9086 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
9087 if ( lp_enable_asu_support() ) {
9088 lp_add_ipc("ADMIN$", false);
9092 set_server_role();
9093 set_default_server_announce_type();
9094 set_allowed_client_auth();
9096 bLoaded = True;
9098 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
9099 /* if bWINSsupport is true and we are in the client */
9100 if (lp_is_in_client() && Globals.bWINSsupport) {
9101 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
9104 init_iconv();
9106 bAllowIncludeRegistry = true;
9108 return (bRetval);
9111 bool lp_load(const char *pszFname,
9112 bool global_only,
9113 bool save_defaults,
9114 bool add_ipc,
9115 bool initialize_globals)
9117 return lp_load_ex(pszFname,
9118 global_only,
9119 save_defaults,
9120 add_ipc,
9121 initialize_globals,
9122 true, false);
9125 bool lp_load_initial_only(const char *pszFname)
9127 return lp_load_ex(pszFname,
9128 true,
9129 false,
9130 false,
9131 true,
9132 false,
9133 false);
9136 bool lp_load_with_registry_shares(const char *pszFname,
9137 bool global_only,
9138 bool save_defaults,
9139 bool add_ipc,
9140 bool initialize_globals)
9142 return lp_load_ex(pszFname,
9143 global_only,
9144 save_defaults,
9145 add_ipc,
9146 initialize_globals,
9147 true,
9148 true);
9151 /***************************************************************************
9152 Return the max number of services.
9153 ***************************************************************************/
9155 int lp_numservices(void)
9157 return (iNumServices);
9160 /***************************************************************************
9161 Display the contents of the services array in human-readable form.
9162 ***************************************************************************/
9164 void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9166 int iService;
9168 if (show_defaults)
9169 defaults_saved = False;
9171 dump_globals(f);
9173 dump_a_service(&sDefault, f);
9175 for (iService = 0; iService < maxtoprint; iService++) {
9176 fprintf(f,"\n");
9177 lp_dump_one(f, show_defaults, iService);
9181 /***************************************************************************
9182 Display the contents of one service in human-readable form.
9183 ***************************************************************************/
9185 void lp_dump_one(FILE * f, bool show_defaults, int snum)
9187 if (VALID(snum)) {
9188 if (ServicePtrs[snum]->szService[0] == '\0')
9189 return;
9190 dump_a_service(ServicePtrs[snum], f);
9194 /***************************************************************************
9195 Return the number of the service with the given name, or -1 if it doesn't
9196 exist. Note that this is a DIFFERENT ANIMAL from the internal function
9197 getservicebyname()! This works ONLY if all services have been loaded, and
9198 does not copy the found service.
9199 ***************************************************************************/
9201 int lp_servicenumber(const char *pszServiceName)
9203 int iService;
9204 fstring serviceName;
9206 if (!pszServiceName) {
9207 return GLOBAL_SECTION_SNUM;
9210 for (iService = iNumServices - 1; iService >= 0; iService--) {
9211 if (VALID(iService) && ServicePtrs[iService]->szService) {
9213 * The substitution here is used to support %U is
9214 * service names
9216 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9217 standard_sub_basic(get_current_username(),
9218 current_user_info.domain,
9219 serviceName,sizeof(serviceName));
9220 if (strequal(serviceName, pszServiceName)) {
9221 break;
9226 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9227 time_t last_mod;
9229 if (!usershare_exists(iService, &last_mod)) {
9230 /* Remove the share security tdb entry for it. */
9231 delete_share_security(lp_servicename(iService));
9232 /* Remove it from the array. */
9233 free_service_byindex(iService);
9234 /* Doesn't exist anymore. */
9235 return GLOBAL_SECTION_SNUM;
9238 /* Has it been modified ? If so delete and reload. */
9239 if (ServicePtrs[iService]->usershare_last_mod < last_mod) {
9240 /* Remove it from the array. */
9241 free_service_byindex(iService);
9242 /* and now reload it. */
9243 iService = load_usershare_service(pszServiceName);
9247 if (iService < 0) {
9248 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9249 return GLOBAL_SECTION_SNUM;
9252 return (iService);
9255 bool share_defined(const char *service_name)
9257 return (lp_servicenumber(service_name) != -1);
9260 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9261 const char *sharename)
9263 struct share_params *result;
9264 char *sname;
9265 int snum;
9267 if (!(sname = SMB_STRDUP(sharename))) {
9268 return NULL;
9271 snum = find_service(sname);
9272 SAFE_FREE(sname);
9274 if (snum < 0) {
9275 return NULL;
9278 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9279 DEBUG(0, ("talloc failed\n"));
9280 return NULL;
9283 result->service = snum;
9284 return result;
9287 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9289 struct share_iterator *result;
9291 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9292 DEBUG(0, ("talloc failed\n"));
9293 return NULL;
9296 result->next_id = 0;
9297 return result;
9300 struct share_params *next_share(struct share_iterator *list)
9302 struct share_params *result;
9304 while (!lp_snum_ok(list->next_id) &&
9305 (list->next_id < lp_numservices())) {
9306 list->next_id += 1;
9309 if (list->next_id >= lp_numservices()) {
9310 return NULL;
9313 if (!(result = TALLOC_P(list, struct share_params))) {
9314 DEBUG(0, ("talloc failed\n"));
9315 return NULL;
9318 result->service = list->next_id;
9319 list->next_id += 1;
9320 return result;
9323 struct share_params *next_printer(struct share_iterator *list)
9325 struct share_params *result;
9327 while ((result = next_share(list)) != NULL) {
9328 if (lp_print_ok(result->service)) {
9329 break;
9332 return result;
9336 * This is a hack for a transition period until we transformed all code from
9337 * service numbers to struct share_params.
9340 struct share_params *snum2params_static(int snum)
9342 static struct share_params result;
9343 result.service = snum;
9344 return &result;
9347 /*******************************************************************
9348 A useful volume label function.
9349 ********************************************************************/
9351 const char *volume_label(int snum)
9353 char *ret;
9354 const char *label = lp_volume(snum);
9355 if (!*label) {
9356 label = lp_servicename(snum);
9359 /* This returns a 33 byte guarenteed null terminated string. */
9360 ret = talloc_strndup(talloc_tos(), label, 32);
9361 if (!ret) {
9362 return "";
9364 return ret;
9367 /*******************************************************************
9368 Set the server type we will announce as via nmbd.
9369 ********************************************************************/
9371 static void set_default_server_announce_type(void)
9373 default_server_announce = 0;
9374 default_server_announce |= SV_TYPE_WORKSTATION;
9375 default_server_announce |= SV_TYPE_SERVER;
9376 default_server_announce |= SV_TYPE_SERVER_UNIX;
9378 /* note that the flag should be set only if we have a
9379 printer service but nmbd doesn't actually load the
9380 services so we can't tell --jerry */
9382 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9384 switch (lp_announce_as()) {
9385 case ANNOUNCE_AS_NT_SERVER:
9386 default_server_announce |= SV_TYPE_SERVER_NT;
9387 /* fall through... */
9388 case ANNOUNCE_AS_NT_WORKSTATION:
9389 default_server_announce |= SV_TYPE_NT;
9390 break;
9391 case ANNOUNCE_AS_WIN95:
9392 default_server_announce |= SV_TYPE_WIN95_PLUS;
9393 break;
9394 case ANNOUNCE_AS_WFW:
9395 default_server_announce |= SV_TYPE_WFW;
9396 break;
9397 default:
9398 break;
9401 switch (lp_server_role()) {
9402 case ROLE_DOMAIN_MEMBER:
9403 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9404 break;
9405 case ROLE_DOMAIN_PDC:
9406 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9407 break;
9408 case ROLE_DOMAIN_BDC:
9409 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9410 break;
9411 case ROLE_STANDALONE:
9412 default:
9413 break;
9415 if (lp_time_server())
9416 default_server_announce |= SV_TYPE_TIME_SOURCE;
9418 if (lp_host_msdfs())
9419 default_server_announce |= SV_TYPE_DFS_SERVER;
9422 /***********************************************************
9423 returns role of Samba server
9424 ************************************************************/
9426 int lp_server_role(void)
9428 return server_role;
9431 /***********************************************************
9432 If we are PDC then prefer us as DMB
9433 ************************************************************/
9435 bool lp_domain_master(void)
9437 if (Globals.iDomainMaster == Auto)
9438 return (lp_server_role() == ROLE_DOMAIN_PDC);
9440 return (bool)Globals.iDomainMaster;
9443 /***********************************************************
9444 If we are DMB then prefer us as LMB
9445 ************************************************************/
9447 bool lp_preferred_master(void)
9449 if (Globals.iPreferredMaster == Auto)
9450 return (lp_local_master() && lp_domain_master());
9452 return (bool)Globals.iPreferredMaster;
9455 /*******************************************************************
9456 Remove a service.
9457 ********************************************************************/
9459 void lp_remove_service(int snum)
9461 ServicePtrs[snum]->valid = False;
9462 invalid_services[num_invalid_services++] = snum;
9465 /*******************************************************************
9466 Copy a service.
9467 ********************************************************************/
9469 void lp_copy_service(int snum, const char *new_name)
9471 do_section(new_name, NULL);
9472 if (snum >= 0) {
9473 snum = lp_servicenumber(new_name);
9474 if (snum >= 0)
9475 lp_do_parameter(snum, "copy", lp_servicename(snum));
9480 /*******************************************************************
9481 Get the default server type we will announce as via nmbd.
9482 ********************************************************************/
9484 int lp_default_server_announce(void)
9486 return default_server_announce;
9489 /*******************************************************************
9490 Split the announce version into major and minor numbers.
9491 ********************************************************************/
9493 int lp_major_announce_version(void)
9495 static bool got_major = False;
9496 static int major_version = DEFAULT_MAJOR_VERSION;
9497 char *vers;
9498 char *p;
9500 if (got_major)
9501 return major_version;
9503 got_major = True;
9504 if ((vers = lp_announce_version()) == NULL)
9505 return major_version;
9507 if ((p = strchr_m(vers, '.')) == 0)
9508 return major_version;
9510 *p = '\0';
9511 major_version = atoi(vers);
9512 return major_version;
9515 int lp_minor_announce_version(void)
9517 static bool got_minor = False;
9518 static int minor_version = DEFAULT_MINOR_VERSION;
9519 char *vers;
9520 char *p;
9522 if (got_minor)
9523 return minor_version;
9525 got_minor = True;
9526 if ((vers = lp_announce_version()) == NULL)
9527 return minor_version;
9529 if ((p = strchr_m(vers, '.')) == 0)
9530 return minor_version;
9532 p++;
9533 minor_version = atoi(p);
9534 return minor_version;
9537 /***********************************************************
9538 Set the global name resolution order (used in smbclient).
9539 ************************************************************/
9541 void lp_set_name_resolve_order(const char *new_order)
9543 string_set(&Globals.szNameResolveOrder, new_order);
9546 const char *lp_printername(int snum)
9548 const char *ret = _lp_printername(snum);
9549 if (ret == NULL || (ret != NULL && *ret == '\0'))
9550 ret = lp_const_servicename(snum);
9552 return ret;
9556 /***********************************************************
9557 Allow daemons such as winbindd to fix their logfile name.
9558 ************************************************************/
9560 void lp_set_logfile(const char *name)
9562 string_set(&Globals.szLogFile, name);
9563 debug_set_logfile(name);
9566 /*******************************************************************
9567 Return the max print jobs per queue.
9568 ********************************************************************/
9570 int lp_maxprintjobs(int snum)
9572 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9573 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9574 maxjobs = PRINT_MAX_JOBID - 1;
9576 return maxjobs;
9579 const char *lp_printcapname(void)
9581 if ((Globals.szPrintcapname != NULL) &&
9582 (Globals.szPrintcapname[0] != '\0'))
9583 return Globals.szPrintcapname;
9585 if (sDefault.iPrinting == PRINT_CUPS) {
9586 #ifdef HAVE_CUPS
9587 return "cups";
9588 #else
9589 return "lpstat";
9590 #endif
9593 if (sDefault.iPrinting == PRINT_BSD)
9594 return "/etc/printcap";
9596 return PRINTCAP_NAME;
9599 /*******************************************************************
9600 Ensure we don't use sendfile if server smb signing is active.
9601 ********************************************************************/
9603 static uint32 spoolss_state;
9605 bool lp_disable_spoolss( void )
9607 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9608 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9610 return spoolss_state == SVCCTL_STOPPED ? True : False;
9613 void lp_set_spoolss_state( uint32 state )
9615 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9617 spoolss_state = state;
9620 uint32 lp_get_spoolss_state( void )
9622 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9625 /*******************************************************************
9626 Ensure we don't use sendfile if server smb signing is active.
9627 ********************************************************************/
9629 bool lp_use_sendfile(int snum)
9631 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9632 if (Protocol < PROTOCOL_NT1) {
9633 return False;
9635 return (_lp_use_sendfile(snum) &&
9636 (get_remote_arch() != RA_WIN95) &&
9637 !srv_is_signing_active());
9640 /*******************************************************************
9641 Turn off sendfile if we find the underlying OS doesn't support it.
9642 ********************************************************************/
9644 void set_use_sendfile(int snum, bool val)
9646 if (LP_SNUM_OK(snum))
9647 ServicePtrs[snum]->bUseSendfile = val;
9648 else
9649 sDefault.bUseSendfile = val;
9652 /*******************************************************************
9653 Turn off storing DOS attributes if this share doesn't support it.
9654 ********************************************************************/
9656 void set_store_dos_attributes(int snum, bool val)
9658 if (!LP_SNUM_OK(snum))
9659 return;
9660 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9663 void lp_set_mangling_method(const char *new_method)
9665 string_set(&Globals.szManglingMethod, new_method);
9668 /*******************************************************************
9669 Global state for POSIX pathname processing.
9670 ********************************************************************/
9672 static bool posix_pathnames;
9674 bool lp_posix_pathnames(void)
9676 return posix_pathnames;
9679 /*******************************************************************
9680 Change everything needed to ensure POSIX pathname processing (currently
9681 not much).
9682 ********************************************************************/
9684 void lp_set_posix_pathnames(void)
9686 posix_pathnames = True;
9689 /*******************************************************************
9690 Global state for POSIX lock processing - CIFS unix extensions.
9691 ********************************************************************/
9693 bool posix_default_lock_was_set;
9694 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9696 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9698 if (posix_default_lock_was_set) {
9699 return posix_cifsx_locktype;
9700 } else {
9701 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9705 /*******************************************************************
9706 ********************************************************************/
9708 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9710 posix_default_lock_was_set = True;
9711 posix_cifsx_locktype = val;
9714 int lp_min_receive_file_size(void)
9716 if (Globals.iminreceivefile < 0) {
9717 return 0;
9719 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9722 /*******************************************************************
9723 If socket address is an empty character string, it is necessary to
9724 define it as "0.0.0.0".
9725 ********************************************************************/
9727 const char *lp_socket_address(void)
9729 char *sock_addr = Globals.szSocketAddress;
9731 if (sock_addr[0] == '\0'){
9732 string_set(&Globals.szSocketAddress, "0.0.0.0");
9734 return Globals.szSocketAddress;