source: branches/samba-3.3.x/source/param/loadparm.c@ 407

Last change on this file since 407 was 407, checked in by Herwig Bauernfeind, 16 years ago

Workaround for Ticket #126 as suggested by the Samba people for 3.3

File size: 254.7 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
5
6 Largely re-written by Andrew Tridgell, September 1994
7
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
13
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.
18
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.
23
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/>.
26*/
27
28/*
29 * Load parameters.
30 *
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.
34 *
35 * To add a parameter:
36 *
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
42 *
43 *
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!
51 *
52 */
53
54#include "includes.h"
55#include "printing.h"
56
57bool bLoaded = False;
58
59extern enum protocol_types Protocol;
60extern userdom_struct current_user_info;
61
62#ifndef GLOBAL_NAME
63#define GLOBAL_NAME "global"
64#endif
65
66#ifndef PRINTERS_NAME
67#define PRINTERS_NAME "printers"
68#endif
69
70#ifndef HOMES_NAME
71#define HOMES_NAME "homes"
72#endif
73
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
81
82static bool in_client = False; /* Not in the client by default */
83static struct smbconf_csn conf_last_csn;
84
85#define CONFIG_BACKEND_FILE 0
86#define CONFIG_BACKEND_REGISTRY 1
87
88static int config_backend = CONFIG_BACKEND_FILE;
89
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)
93
94#define USERSHARE_VALID 1
95#define USERSHARE_PENDING_DELETE 2
96
97extern int extra_time_offset;
98
99static bool defaults_saved = False;
100
101struct param_opt_struct {
102 struct param_opt_struct *prev, *next;
103 char *key;
104 char *value;
105 char **list;
106};
107
108/*
109 * This structure describes global (ie., server-wide) parameters.
110 */
111struct global {
112 int ConfigBackend;
113 char *smb_ports;
114 char *dos_charset;
115 char *unix_charset;
116 char *display_charset;
117 char *szPrintcapname;
118 char *szAddPortCommand;
119 char *szEnumPortsCommand;
120 char *szAddPrinterCommand;
121 char *szDeletePrinterCommand;
122 char *szOs2DriverMap;
123 char *szLockDir;
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 bool bUseKerberosKeytab;
327 bool bDeferSharingViolations;
328 bool bEnablePrivileges;
329 bool bASUSupport;
330 bool bUsershareOwnerOnly;
331 bool bUsershareAllowGuests;
332 bool bRegistryShares;
333 int restrict_anonymous;
334 int name_cache_timeout;
335 int client_signing;
336 int server_signing;
337 int client_ldap_sasl_wrapping;
338 int iUsershareMaxShares;
339 int iIdmapCacheTime;
340 int iIdmapNegativeCacheTime;
341 bool bResetOnZeroVC;
342 int iKeepalive;
343 int iminreceivefile;
344 struct param_opt_struct *param_opt;
345 int cups_connection_timeout;
346};
347
348static struct global Globals;
349
350/*
351 * This structure describes a single service.
352 */
353struct service {
354 bool valid;
355 bool autoloaded;
356 int usershare;
357 time_t usershare_last_mod;
358 char *szService;
359 char *szPath;
360 char *szUsername;
361 char **szInvalidUsers;
362 char **szValidUsers;
363 char **szAdminUsers;
364 char *szCopy;
365 char *szInclude;
366 char *szPreExec;
367 char *szPostExec;
368 char *szRootPreExec;
369 char *szRootPostExec;
370 char *szCupsOptions;
371 char *szPrintcommand;
372 char *szLpqcommand;
373 char *szLprmcommand;
374 char *szLppausecommand;
375 char *szLpresumecommand;
376 char *szQueuepausecommand;
377 char *szQueueresumecommand;
378 char *szPrintername;
379 char *szPrintjobUsername;
380 char *szDontdescend;
381 char **szHostsallow;
382 char **szHostsdeny;
383 char *szMagicScript;
384 char *szMagicOutput;
385 char *szVetoFiles;
386 char *szHideFiles;
387 char *szVetoOplockFiles;
388 char *comment;
389 char *force_user;
390 char *force_group;
391 char **readlist;
392 char **writelist;
393 char **printer_admin;
394 char *volume;
395 char *fstype;
396 char **szVfsObjects;
397 char *szMSDfsProxy;
398 char *szAioWriteBehind;
399 char *szDfree;
400 int iMinPrintSpace;
401 int iMaxPrintJobs;
402 int iMaxReportedPrintJobs;
403 int iWriteCacheSize;
404 int iCreate_mask;
405 int iCreate_force_mode;
406 int iSecurity_mask;
407 int iSecurity_force_mode;
408 int iDir_mask;
409 int iDir_force_mode;
410 int iDir_Security_mask;
411 int iDir_Security_force_mode;
412 int iMaxConnections;
413 int iDefaultCase;
414 int iPrinting;
415 int iOplockContentionLimit;
416 int iCSCPolicy;
417 int iBlock_size;
418 int iDfreeCacheTime;
419 bool bPreexecClose;
420 bool bRootpreexecClose;
421 int iCaseSensitive;
422 bool bCasePreserve;
423 bool bShortCasePreserve;
424 bool bHideDotFiles;
425 bool bHideSpecialFiles;
426 bool bHideUnReadable;
427 bool bHideUnWriteableFiles;
428 bool bBrowseable;
429 bool bAvailable;
430 bool bRead_only;
431 bool bNo_set_dir;
432 bool bGuest_only;
433 bool bAdministrative_share;
434 bool bGuest_ok;
435 bool bPrint_ok;
436 bool bMap_system;
437 bool bMap_hidden;
438 bool bMap_archive;
439 bool bStoreDosAttributes;
440 bool bDmapiSupport;
441 bool bLocking;
442 int iStrictLocking;
443 bool bPosixLocking;
444 bool bShareModes;
445 bool bOpLocks;
446 bool bLevel2OpLocks;
447 bool bOnlyUser;
448 bool bMangledNames;
449 bool bWidelinks;
450 bool bSymlinks;
451 bool bSyncAlways;
452 bool bStrictAllocate;
453 bool bStrictSync;
454 char magic_char;
455 struct bitmap *copymap;
456 bool bDeleteReadonly;
457 bool bFakeOplocks;
458 bool bDeleteVetoFiles;
459 bool bDosFilemode;
460 bool bDosFiletimes;
461 bool bDosFiletimeResolution;
462 bool bFakeDirCreateTimes;
463 bool bBlockingLocks;
464 bool bInheritPerms;
465 bool bInheritACLS;
466 bool bInheritOwner;
467 bool bMSDfsRoot;
468 bool bUseClientDriver;
469 bool bDefaultDevmode;
470 bool bForcePrintername;
471 bool bNTAclSupport;
472 bool bForceUnknownAclUser;
473 bool bUseSendfile;
474 bool bProfileAcls;
475 bool bMap_acl_inherit;
476 bool bAfs_Share;
477 bool bEASupport;
478 bool bAclCheckPermissions;
479 bool bAclMapFullControl;
480 bool bAclGroupControl;
481 bool bChangeNotify;
482 bool bKernelChangeNotify;
483 int iallocation_roundup_size;
484 int iAioReadSize;
485 int iAioWriteSize;
486 int iMap_readonly;
487 int iDirectoryNameCacheSize;
488 int ismb_encrypt;
489 struct param_opt_struct *param_opt;
490
491 char dummy[3]; /* for alignment */
492};
493
494
495/* This is a default service used to prime a services structure */
496static struct service sDefault = {
497 True, /* valid */
498 False, /* not autoloaded */
499 0, /* not a usershare */
500 (time_t)0, /* No last mod time */
501 NULL, /* szService */
502 NULL, /* szPath */
503 NULL, /* szUsername */
504 NULL, /* szInvalidUsers */
505 NULL, /* szValidUsers */
506 NULL, /* szAdminUsers */
507 NULL, /* szCopy */
508 NULL, /* szInclude */
509 NULL, /* szPreExec */
510 NULL, /* szPostExec */
511 NULL, /* szRootPreExec */
512 NULL, /* szRootPostExec */
513 NULL, /* szCupsOptions */
514 NULL, /* szPrintcommand */
515 NULL, /* szLpqcommand */
516 NULL, /* szLprmcommand */
517 NULL, /* szLppausecommand */
518 NULL, /* szLpresumecommand */
519 NULL, /* szQueuepausecommand */
520 NULL, /* szQueueresumecommand */
521 NULL, /* szPrintername */
522 NULL, /* szPrintjobUsername */
523 NULL, /* szDontdescend */
524 NULL, /* szHostsallow */
525 NULL, /* szHostsdeny */
526 NULL, /* szMagicScript */
527 NULL, /* szMagicOutput */
528 NULL, /* szVetoFiles */
529 NULL, /* szHideFiles */
530 NULL, /* szVetoOplockFiles */
531 NULL, /* comment */
532 NULL, /* force user */
533 NULL, /* force group */
534 NULL, /* readlist */
535 NULL, /* writelist */
536 NULL, /* printer admin */
537 NULL, /* volume */
538 NULL, /* fstype */
539 NULL, /* vfs objects */
540 NULL, /* szMSDfsProxy */
541 NULL, /* szAioWriteBehind */
542 NULL, /* szDfree */
543 0, /* iMinPrintSpace */
544 1000, /* iMaxPrintJobs */
545 0, /* iMaxReportedPrintJobs */
546 0, /* iWriteCacheSize */
547 0744, /* iCreate_mask */
548 0000, /* iCreate_force_mode */
549 0777, /* iSecurity_mask */
550 0, /* iSecurity_force_mode */
551 0755, /* iDir_mask */
552 0000, /* iDir_force_mode */
553 0777, /* iDir_Security_mask */
554 0, /* iDir_Security_force_mode */
555 0, /* iMaxConnections */
556 CASE_LOWER, /* iDefaultCase */
557 DEFAULT_PRINTING, /* iPrinting */
558 2, /* iOplockContentionLimit */
559 0, /* iCSCPolicy */
560 1024, /* iBlock_size */
561 0, /* iDfreeCacheTime */
562 False, /* bPreexecClose */
563 False, /* bRootpreexecClose */
564 Auto, /* case sensitive */
565 True, /* case preserve */
566 True, /* short case preserve */
567 True, /* bHideDotFiles */
568 False, /* bHideSpecialFiles */
569 False, /* bHideUnReadable */
570 False, /* bHideUnWriteableFiles */
571 True, /* bBrowseable */
572 True, /* bAvailable */
573 True, /* bRead_only */
574 True, /* bNo_set_dir */
575 False, /* bGuest_only */
576 False, /* bAdministrative_share */
577 False, /* bGuest_ok */
578 False, /* bPrint_ok */
579 False, /* bMap_system */
580 False, /* bMap_hidden */
581 True, /* bMap_archive */
582 False, /* bStoreDosAttributes */
583 False, /* bDmapiSupport */
584 True, /* bLocking */
585 Auto, /* iStrictLocking */
586 True, /* bPosixLocking */
587 True, /* bShareModes */
588 True, /* bOpLocks */
589 True, /* bLevel2OpLocks */
590 False, /* bOnlyUser */
591 True, /* bMangledNames */
592#ifndef __OS2__
593 /* Future default in newer Samba versions */
594 True, /* bWidelinks */
595#else
596 False, /* bWidelinks */
597#endif
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 */
642
643 "" /* dummy */
644};
645
646/* local variables */
647static struct service **ServicePtrs = NULL;
648static int iNumServices = 0;
649static int iServiceIndex = 0;
650static struct db_context *ServiceHash;
651static int *invalid_services = NULL;
652static int num_invalid_services = 0;
653static bool bInGlobalSection = True;
654static bool bGlobalOnly = False;
655static int server_role;
656static int default_server_announce;
657
658#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
659
660/* prototypes for the special type handlers */
661static bool handle_include( int snum, const char *pszParmValue, char **ptr);
662static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
663static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
664static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
665static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
666static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
667static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
668static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
669static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
670static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
671static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
672static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
673
674static void set_server_role(void);
675static void set_default_server_announce_type(void);
676static void set_allowed_client_auth(void);
677
678static void add_to_file_list(const char *fname, const char *subfname);
679
680static const struct enum_list enum_protocol[] = {
681 {PROTOCOL_NT1, "NT1"},
682 {PROTOCOL_LANMAN2, "LANMAN2"},
683 {PROTOCOL_LANMAN1, "LANMAN1"},
684 {PROTOCOL_CORE, "CORE"},
685 {PROTOCOL_COREPLUS, "COREPLUS"},
686 {PROTOCOL_COREPLUS, "CORE+"},
687 {-1, NULL}
688};
689
690static const struct enum_list enum_security[] = {
691 {SEC_SHARE, "SHARE"},
692 {SEC_USER, "USER"},
693 {SEC_SERVER, "SERVER"},
694 {SEC_DOMAIN, "DOMAIN"},
695#ifdef HAVE_ADS
696 {SEC_ADS, "ADS"},
697#endif
698 {-1, NULL}
699};
700
701static const struct enum_list enum_printing[] = {
702 {PRINT_SYSV, "sysv"},
703 {PRINT_AIX, "aix"},
704 {PRINT_HPUX, "hpux"},
705 {PRINT_BSD, "bsd"},
706 {PRINT_QNX, "qnx"},
707 {PRINT_PLP, "plp"},
708 {PRINT_LPRNG, "lprng"},
709 {PRINT_CUPS, "cups"},
710 {PRINT_IPRINT, "iprint"},
711 {PRINT_LPRNT, "nt"},
712 {PRINT_LPROS2, "os2"},
713#ifdef DEVELOPER
714 {PRINT_TEST, "test"},
715 {PRINT_VLP, "vlp"},
716#endif /* DEVELOPER */
717 {-1, NULL}
718};
719
720static const struct enum_list enum_ldap_sasl_wrapping[] = {
721 {0, "plain"},
722 {ADS_AUTH_SASL_SIGN, "sign"},
723 {ADS_AUTH_SASL_SEAL, "seal"},
724 {-1, NULL}
725};
726
727static const struct enum_list enum_ldap_ssl[] = {
728 {LDAP_SSL_OFF, "no"},
729 {LDAP_SSL_OFF, "off"},
730 {LDAP_SSL_START_TLS, "start tls"},
731 {LDAP_SSL_START_TLS, "start_tls"},
732 {-1, NULL}
733};
734
735static const struct enum_list enum_ldap_passwd_sync[] = {
736 {LDAP_PASSWD_SYNC_OFF, "no"},
737 {LDAP_PASSWD_SYNC_OFF, "off"},
738 {LDAP_PASSWD_SYNC_ON, "yes"},
739 {LDAP_PASSWD_SYNC_ON, "on"},
740 {LDAP_PASSWD_SYNC_ONLY, "only"},
741 {-1, NULL}
742};
743
744/* Types of machine we can announce as. */
745#define ANNOUNCE_AS_NT_SERVER 1
746#define ANNOUNCE_AS_WIN95 2
747#define ANNOUNCE_AS_WFW 3
748#define ANNOUNCE_AS_NT_WORKSTATION 4
749
750static const struct enum_list enum_announce_as[] = {
751 {ANNOUNCE_AS_NT_SERVER, "NT"},
752 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
753 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
754 {ANNOUNCE_AS_WIN95, "win95"},
755 {ANNOUNCE_AS_WFW, "WfW"},
756 {-1, NULL}
757};
758
759static const struct enum_list enum_map_readonly[] = {
760 {MAP_READONLY_NO, "no"},
761 {MAP_READONLY_NO, "false"},
762 {MAP_READONLY_NO, "0"},
763 {MAP_READONLY_YES, "yes"},
764 {MAP_READONLY_YES, "true"},
765 {MAP_READONLY_YES, "1"},
766 {MAP_READONLY_PERMISSIONS, "permissions"},
767 {MAP_READONLY_PERMISSIONS, "perms"},
768 {-1, NULL}
769};
770
771static const struct enum_list enum_case[] = {
772 {CASE_LOWER, "lower"},
773 {CASE_UPPER, "upper"},
774 {-1, NULL}
775};
776
777static const struct enum_list enum_bool_auto[] = {
778 {False, "No"},
779 {False, "False"},
780 {False, "0"},
781 {True, "Yes"},
782 {True, "True"},
783 {True, "1"},
784 {Auto, "Auto"},
785 {-1, NULL}
786};
787
788/* Client-side offline caching policy types */
789#define CSC_POLICY_MANUAL 0
790#define CSC_POLICY_DOCUMENTS 1
791#define CSC_POLICY_PROGRAMS 2
792#define CSC_POLICY_DISABLE 3
793
794static const struct enum_list enum_csc_policy[] = {
795 {CSC_POLICY_MANUAL, "manual"},
796 {CSC_POLICY_DOCUMENTS, "documents"},
797 {CSC_POLICY_PROGRAMS, "programs"},
798 {CSC_POLICY_DISABLE, "disable"},
799 {-1, NULL}
800};
801
802/* SMB signing types. */
803static const struct enum_list enum_smb_signing_vals[] = {
804 {False, "No"},
805 {False, "False"},
806 {False, "0"},
807 {False, "Off"},
808 {False, "disabled"},
809 {True, "Yes"},
810 {True, "True"},
811 {True, "1"},
812 {True, "On"},
813 {True, "enabled"},
814 {Auto, "auto"},
815 {Required, "required"},
816 {Required, "mandatory"},
817 {Required, "force"},
818 {Required, "forced"},
819 {Required, "enforced"},
820 {-1, NULL}
821};
822
823/* ACL compatibility options. */
824static const struct enum_list enum_acl_compat_vals[] = {
825 { ACL_COMPAT_AUTO, "auto" },
826 { ACL_COMPAT_WINNT, "winnt" },
827 { ACL_COMPAT_WIN2K, "win2k" },
828 { -1, NULL}
829};
830
831/*
832 Do you want session setups at user level security with a invalid
833 password to be rejected or allowed in as guest? WinNT rejects them
834 but it can be a pain as it means "net view" needs to use a password
835
836 You have 3 choices in the setting of map_to_guest:
837
838 "Never" means session setups with an invalid password
839 are rejected. This is the default.
840
841 "Bad User" means session setups with an invalid password
842 are rejected, unless the username does not exist, in which case it
843 is treated as a guest login
844
845 "Bad Password" means session setups with an invalid password
846 are treated as a guest login
847
848 Note that map_to_guest only has an effect in user or server
849 level security.
850*/
851
852static const struct enum_list enum_map_to_guest[] = {
853 {NEVER_MAP_TO_GUEST, "Never"},
854 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
855 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
856 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
857 {-1, NULL}
858};
859
860/* Config backend options */
861
862static const struct enum_list enum_config_backend[] = {
863 {CONFIG_BACKEND_FILE, "file"},
864 {CONFIG_BACKEND_REGISTRY, "registry"},
865 {-1, NULL}
866};
867
868/* Note: We do not initialise the defaults union - it is not allowed in ANSI C
869 *
870 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
871 * screen in SWAT. This is used to exclude parameters as well as to squash all
872 * parameters that have been duplicated by pseudonyms.
873 *
874 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
875 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
876 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
877 * respective views.
878 *
879 * NOTE2: Handling of duplicated (synonym) parameters:
880 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
881 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
882 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
883 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
884 */
885
886static struct parm_struct parm_table[] = {
887 {N_("Base Options"), P_SEP, P_SEPARATOR},
888
889 {
890 .label = "dos charset",
891 .type = P_STRING,
892 .p_class = P_GLOBAL,
893 .ptr = &Globals.dos_charset,
894 .special = handle_charset,
895 .enum_list = NULL,
896 .flags = FLAG_ADVANCED
897 },
898 {
899 .label = "unix charset",
900 .type = P_STRING,
901 .p_class = P_GLOBAL,
902 .ptr = &Globals.unix_charset,
903 .special = handle_charset,
904 .enum_list = NULL,
905 .flags = FLAG_ADVANCED
906 },
907 {
908 .label = "display charset",
909 .type = P_STRING,
910 .p_class = P_GLOBAL,
911 .ptr = &Globals.display_charset,
912 .special = handle_charset,
913 .enum_list = NULL,
914 .flags = FLAG_ADVANCED
915 },
916 {
917 .label = "comment",
918 .type = P_STRING,
919 .p_class = P_LOCAL,
920 .ptr = &sDefault.comment,
921 .special = NULL,
922 .enum_list = NULL,
923 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
924 },
925 {
926 .label = "path",
927 .type = P_STRING,
928 .p_class = P_LOCAL,
929 .ptr = &sDefault.szPath,
930 .special = NULL,
931 .enum_list = NULL,
932 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
933 },
934 {
935 .label = "directory",
936 .type = P_STRING,
937 .p_class = P_LOCAL,
938 .ptr = &sDefault.szPath,
939 .special = NULL,
940 .enum_list = NULL,
941 .flags = FLAG_HIDE,
942 },
943 {
944 .label = "workgroup",
945 .type = P_USTRING,
946 .p_class = P_GLOBAL,
947 .ptr = &Globals.szWorkgroup,
948 .special = handle_workgroup,
949 .enum_list = NULL,
950 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
951 },
952#ifdef WITH_ADS
953 {
954 .label = "realm",
955 .type = P_USTRING,
956 .p_class = P_GLOBAL,
957 .ptr = &Globals.szRealm,
958 .special = NULL,
959 .enum_list = NULL,
960 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
961 },
962#endif
963 {
964 .label = "netbios name",
965 .type = P_USTRING,
966 .p_class = P_GLOBAL,
967 .ptr = &Globals.szNetbiosName,
968 .special = handle_netbios_name,
969 .enum_list = NULL,
970 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
971 },
972 {
973 .label = "netbios aliases",
974 .type = P_LIST,
975 .p_class = P_GLOBAL,
976 .ptr = &Globals.szNetbiosAliases,
977 .special = handle_netbios_aliases,
978 .enum_list = NULL,
979 .flags = FLAG_ADVANCED,
980 },
981 {
982 .label = "netbios scope",
983 .type = P_USTRING,
984 .p_class = P_GLOBAL,
985 .ptr = &Globals.szNetbiosScope,
986 .special = handle_netbios_scope,
987 .enum_list = NULL,
988 .flags = FLAG_ADVANCED,
989 },
990 {
991 .label = "server string",
992 .type = P_STRING,
993 .p_class = P_GLOBAL,
994 .ptr = &Globals.szServerString,
995 .special = NULL,
996 .enum_list = NULL,
997 .flags = FLAG_BASIC | FLAG_ADVANCED,
998 },
999 {
1000 .label = "interfaces",
1001 .type = P_LIST,
1002 .p_class = P_GLOBAL,
1003 .ptr = &Globals.szInterfaces,
1004 .special = NULL,
1005 .enum_list = NULL,
1006 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1007 },
1008 {
1009 .label = "bind interfaces only",
1010 .type = P_BOOL,
1011 .p_class = P_GLOBAL,
1012 .ptr = &Globals.bBindInterfacesOnly,
1013 .special = NULL,
1014 .enum_list = NULL,
1015 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1016 },
1017 {
1018 .label = "config backend",
1019 .type = P_ENUM,
1020 .p_class = P_GLOBAL,
1021 .ptr = &Globals.ConfigBackend,
1022 .special = NULL,
1023 .enum_list = enum_config_backend,
1024 .flags = FLAG_ADVANCED,
1025 },
1026
1027 {N_("Security Options"), P_SEP, P_SEPARATOR},
1028
1029 {
1030 .label = "security",
1031 .type = P_ENUM,
1032 .p_class = P_GLOBAL,
1033 .ptr = &Globals.security,
1034 .special = NULL,
1035 .enum_list = enum_security,
1036 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1037 },
1038 {
1039 .label = "auth methods",
1040 .type = P_LIST,
1041 .p_class = P_GLOBAL,
1042 .ptr = &Globals.AuthMethods,
1043 .special = NULL,
1044 .enum_list = NULL,
1045 .flags = FLAG_ADVANCED,
1046 },
1047 {
1048 .label = "encrypt passwords",
1049 .type = P_BOOL,
1050 .p_class = P_GLOBAL,
1051 .ptr = &Globals.bEncryptPasswords,
1052 .special = NULL,
1053 .enum_list = NULL,
1054 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1055 },
1056 {
1057 .label = "update encrypted",
1058 .type = P_BOOL,
1059 .p_class = P_GLOBAL,
1060 .ptr = &Globals.bUpdateEncrypt,
1061 .special = NULL,
1062 .enum_list = NULL,
1063 .flags = FLAG_ADVANCED,
1064 },
1065 {
1066 .label = "client schannel",
1067 .type = P_ENUM,
1068 .p_class = P_GLOBAL,
1069 .ptr = &Globals.clientSchannel,
1070 .special = NULL,
1071 .enum_list = enum_bool_auto,
1072 .flags = FLAG_BASIC | FLAG_ADVANCED,
1073 },
1074 {
1075 .label = "server schannel",
1076 .type = P_ENUM,
1077 .p_class = P_GLOBAL,
1078 .ptr = &Globals.serverSchannel,
1079 .special = NULL,
1080 .enum_list = enum_bool_auto,
1081 .flags = FLAG_BASIC | FLAG_ADVANCED,
1082 },
1083 {
1084 .label = "allow trusted domains",
1085 .type = P_BOOL,
1086 .p_class = P_GLOBAL,
1087 .ptr = &Globals.bAllowTrustedDomains,
1088 .special = NULL,
1089 .enum_list = NULL,
1090 .flags = FLAG_ADVANCED,
1091 },
1092 {
1093 .label = "map to guest",
1094 .type = P_ENUM,
1095 .p_class = P_GLOBAL,
1096 .ptr = &Globals.map_to_guest,
1097 .special = NULL,
1098 .enum_list = enum_map_to_guest,
1099 .flags = FLAG_ADVANCED,
1100 },
1101 {
1102 .label = "null passwords",
1103 .type = P_BOOL,
1104 .p_class = P_GLOBAL,
1105 .ptr = &Globals.bNullPasswords,
1106 .special = NULL,
1107 .enum_list = NULL,
1108 .flags = FLAG_ADVANCED,
1109 },
1110 {
1111 .label = "obey pam restrictions",
1112 .type = P_BOOL,
1113 .p_class = P_GLOBAL,
1114 .ptr = &Globals.bObeyPamRestrictions,
1115 .special = NULL,
1116 .enum_list = NULL,
1117 .flags = FLAG_ADVANCED,
1118 },
1119 {
1120 .label = "password server",
1121 .type = P_STRING,
1122 .p_class = P_GLOBAL,
1123 .ptr = &Globals.szPasswordServer,
1124 .special = NULL,
1125 .enum_list = NULL,
1126 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1127 },
1128 {
1129 .label = "smb passwd file",
1130 .type = P_STRING,
1131 .p_class = P_GLOBAL,
1132 .ptr = &Globals.szSMBPasswdFile,
1133 .special = NULL,
1134 .enum_list = NULL,
1135 .flags = FLAG_ADVANCED,
1136 },
1137 {
1138 .label = "private dir",
1139 .type = P_STRING,
1140 .p_class = P_GLOBAL,
1141 .ptr = &Globals.szPrivateDir,
1142 .special = NULL,
1143 .enum_list = NULL,
1144 .flags = FLAG_ADVANCED,
1145 },
1146 {
1147 .label = "passdb backend",
1148 .type = P_STRING,
1149 .p_class = P_GLOBAL,
1150 .ptr = &Globals.szPassdbBackend,
1151 .special = NULL,
1152 .enum_list = NULL,
1153 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1154 },
1155 {
1156 .label = "algorithmic rid base",
1157 .type = P_INTEGER,
1158 .p_class = P_GLOBAL,
1159 .ptr = &Globals.AlgorithmicRidBase,
1160 .special = NULL,
1161 .enum_list = NULL,
1162 .flags = FLAG_ADVANCED,
1163 },
1164 {
1165 .label = "root directory",
1166 .type = P_STRING,
1167 .p_class = P_GLOBAL,
1168 .ptr = &Globals.szRootdir,
1169 .special = NULL,
1170 .enum_list = NULL,
1171 .flags = FLAG_ADVANCED,
1172 },
1173 {
1174 .label = "root dir",
1175 .type = P_STRING,
1176 .p_class = P_GLOBAL,
1177 .ptr = &Globals.szRootdir,
1178 .special = NULL,
1179 .enum_list = NULL,
1180 .flags = FLAG_HIDE,
1181 },
1182 {
1183 .label = "root",
1184 .type = P_STRING,
1185 .p_class = P_GLOBAL,
1186 .ptr = &Globals.szRootdir,
1187 .special = NULL,
1188 .enum_list = NULL,
1189 .flags = FLAG_HIDE,
1190 },
1191 {
1192 .label = "guest account",
1193 .type = P_STRING,
1194 .p_class = P_GLOBAL,
1195 .ptr = &Globals.szGuestaccount,
1196 .special = NULL,
1197 .enum_list = NULL,
1198 .flags = FLAG_BASIC | FLAG_ADVANCED,
1199 },
1200 {
1201 .label = "enable privileges",
1202 .type = P_BOOL,
1203 .p_class = P_GLOBAL,
1204 .ptr = &Globals.bEnablePrivileges,
1205 .special = NULL,
1206 .enum_list = NULL,
1207 .flags = FLAG_ADVANCED,
1208 },
1209
1210 {
1211 .label = "pam password change",
1212 .type = P_BOOL,
1213 .p_class = P_GLOBAL,
1214 .ptr = &Globals.bPamPasswordChange,
1215 .special = NULL,
1216 .enum_list = NULL,
1217 .flags = FLAG_ADVANCED,
1218 },
1219 {
1220 .label = "passwd program",
1221 .type = P_STRING,
1222 .p_class = P_GLOBAL,
1223 .ptr = &Globals.szPasswdProgram,
1224 .special = NULL,
1225 .enum_list = NULL,
1226 .flags = FLAG_ADVANCED,
1227 },
1228 {
1229 .label = "passwd chat",
1230 .type = P_STRING,
1231 .p_class = P_GLOBAL,
1232 .ptr = &Globals.szPasswdChat,
1233 .special = NULL,
1234 .enum_list = NULL,
1235 .flags = FLAG_ADVANCED,
1236 },
1237 {
1238 .label = "passwd chat debug",
1239 .type = P_BOOL,
1240 .p_class = P_GLOBAL,
1241 .ptr = &Globals.bPasswdChatDebug,
1242 .special = NULL,
1243 .enum_list = NULL,
1244 .flags = FLAG_ADVANCED,
1245 },
1246 {
1247 .label = "passwd chat timeout",
1248 .type = P_INTEGER,
1249 .p_class = P_GLOBAL,
1250 .ptr = &Globals.iPasswdChatTimeout,
1251 .special = NULL,
1252 .enum_list = NULL,
1253 .flags = FLAG_ADVANCED,
1254 },
1255 {
1256 .label = "check password script",
1257 .type = P_STRING,
1258 .p_class = P_GLOBAL,
1259 .ptr = &Globals.szCheckPasswordScript,
1260 .special = NULL,
1261 .enum_list = NULL,
1262 .flags = FLAG_ADVANCED,
1263 },
1264 {
1265 .label = "username map",
1266 .type = P_STRING,
1267 .p_class = P_GLOBAL,
1268 .ptr = &Globals.szUsernameMap,
1269 .special = NULL,
1270 .enum_list = NULL,
1271 .flags = FLAG_ADVANCED,
1272 },
1273 {
1274 .label = "password level",
1275 .type = P_INTEGER,
1276 .p_class = P_GLOBAL,
1277 .ptr = &Globals.pwordlevel,
1278 .special = NULL,
1279 .enum_list = NULL,
1280 .flags = FLAG_ADVANCED,
1281 },
1282 {
1283 .label = "username level",
1284 .type = P_INTEGER,
1285 .p_class = P_GLOBAL,
1286 .ptr = &Globals.unamelevel,
1287 .special = NULL,
1288 .enum_list = NULL,
1289 .flags = FLAG_ADVANCED,
1290 },
1291 {
1292 .label = "unix password sync",
1293 .type = P_BOOL,
1294 .p_class = P_GLOBAL,
1295 .ptr = &Globals.bUnixPasswdSync,
1296 .special = NULL,
1297 .enum_list = NULL,
1298 .flags = FLAG_ADVANCED,
1299 },
1300 {
1301 .label = "restrict anonymous",
1302 .type = P_INTEGER,
1303 .p_class = P_GLOBAL,
1304 .ptr = &Globals.restrict_anonymous,
1305 .special = NULL,
1306 .enum_list = NULL,
1307 .flags = FLAG_ADVANCED,
1308 },
1309 {
1310 .label = "lanman auth",
1311 .type = P_BOOL,
1312 .p_class = P_GLOBAL,
1313 .ptr = &Globals.bLanmanAuth,
1314 .special = NULL,
1315 .enum_list = NULL,
1316 .flags = FLAG_ADVANCED,
1317 },
1318 {
1319 .label = "ntlm auth",
1320 .type = P_BOOL,
1321 .p_class = P_GLOBAL,
1322 .ptr = &Globals.bNTLMAuth,
1323 .special = NULL,
1324 .enum_list = NULL,
1325 .flags = FLAG_ADVANCED,
1326 },
1327 {
1328 .label = "client NTLMv2 auth",
1329 .type = P_BOOL,
1330 .p_class = P_GLOBAL,
1331 .ptr = &Globals.bClientNTLMv2Auth,
1332 .special = NULL,
1333 .enum_list = NULL,
1334 .flags = FLAG_ADVANCED,
1335 },
1336 {
1337 .label = "client lanman auth",
1338 .type = P_BOOL,
1339 .p_class = P_GLOBAL,
1340 .ptr = &Globals.bClientLanManAuth,
1341 .special = NULL,
1342 .enum_list = NULL,
1343 .flags = FLAG_ADVANCED,
1344 },
1345 {
1346 .label = "client plaintext auth",
1347 .type = P_BOOL,
1348 .p_class = P_GLOBAL,
1349 .ptr = &Globals.bClientPlaintextAuth,
1350 .special = NULL,
1351 .enum_list = NULL,
1352 .flags = FLAG_ADVANCED,
1353 },
1354 {
1355 .label = "username",
1356 .type = P_STRING,
1357 .p_class = P_LOCAL,
1358 .ptr = &sDefault.szUsername,
1359 .special = NULL,
1360 .enum_list = NULL,
1361 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1362 },
1363 {
1364 .label = "user",
1365 .type = P_STRING,
1366 .p_class = P_LOCAL,
1367 .ptr = &sDefault.szUsername,
1368 .special = NULL,
1369 .enum_list = NULL,
1370 .flags = FLAG_HIDE,
1371 },
1372 {
1373 .label = "users",
1374 .type = P_STRING,
1375 .p_class = P_LOCAL,
1376 .ptr = &sDefault.szUsername,
1377 .special = NULL,
1378 .enum_list = NULL,
1379 .flags = FLAG_HIDE,
1380 },
1381 {
1382 .label = "invalid users",
1383 .type = P_LIST,
1384 .p_class = P_LOCAL,
1385 .ptr = &sDefault.szInvalidUsers,
1386 .special = NULL,
1387 .enum_list = NULL,
1388 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1389 },
1390 {
1391 .label = "valid users",
1392 .type = P_LIST,
1393 .p_class = P_LOCAL,
1394 .ptr = &sDefault.szValidUsers,
1395 .special = NULL,
1396 .enum_list = NULL,
1397 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1398 },
1399 {
1400 .label = "admin users",
1401 .type = P_LIST,
1402 .p_class = P_LOCAL,
1403 .ptr = &sDefault.szAdminUsers,
1404 .special = NULL,
1405 .enum_list = NULL,
1406 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1407 },
1408 {
1409 .label = "read list",
1410 .type = P_LIST,
1411 .p_class = P_LOCAL,
1412 .ptr = &sDefault.readlist,
1413 .special = NULL,
1414 .enum_list = NULL,
1415 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1416 },
1417 {
1418 .label = "write list",
1419 .type = P_LIST,
1420 .p_class = P_LOCAL,
1421 .ptr = &sDefault.writelist,
1422 .special = NULL,
1423 .enum_list = NULL,
1424 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1425 },
1426 {
1427 .label = "printer admin",
1428 .type = P_LIST,
1429 .p_class = P_LOCAL,
1430 .ptr = &sDefault.printer_admin,
1431 .special = NULL,
1432 .enum_list = NULL,
1433 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1434 },
1435 {
1436 .label = "force user",
1437 .type = P_STRING,
1438 .p_class = P_LOCAL,
1439 .ptr = &sDefault.force_user,
1440 .special = NULL,
1441 .enum_list = NULL,
1442 .flags = FLAG_ADVANCED | FLAG_SHARE,
1443 },
1444 {
1445 .label = "force group",
1446 .type = P_STRING,
1447 .p_class = P_LOCAL,
1448 .ptr = &sDefault.force_group,
1449 .special = NULL,
1450 .enum_list = NULL,
1451 .flags = FLAG_ADVANCED | FLAG_SHARE,
1452 },
1453 {
1454 .label = "group",
1455 .type = P_STRING,
1456 .p_class = P_LOCAL,
1457 .ptr = &sDefault.force_group,
1458 .special = NULL,
1459 .enum_list = NULL,
1460 .flags = FLAG_ADVANCED,
1461 },
1462 {
1463 .label = "read only",
1464 .type = P_BOOL,
1465 .p_class = P_LOCAL,
1466 .ptr = &sDefault.bRead_only,
1467 .special = NULL,
1468 .enum_list = NULL,
1469 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1470 },
1471 {
1472 .label = "write ok",
1473 .type = P_BOOLREV,
1474 .p_class = P_LOCAL,
1475 .ptr = &sDefault.bRead_only,
1476 .special = NULL,
1477 .enum_list = NULL,
1478 .flags = FLAG_HIDE,
1479 },
1480 {
1481 .label = "writeable",
1482 .type = P_BOOLREV,
1483 .p_class = P_LOCAL,
1484 .ptr = &sDefault.bRead_only,
1485 .special = NULL,
1486 .enum_list = NULL,
1487 .flags = FLAG_HIDE,
1488 },
1489 {
1490 .label = "writable",
1491 .type = P_BOOLREV,
1492 .p_class = P_LOCAL,
1493 .ptr = &sDefault.bRead_only,
1494 .special = NULL,
1495 .enum_list = NULL,
1496 .flags = FLAG_HIDE,
1497 },
1498 {
1499 .label = "acl check permissions",
1500 .type = P_BOOL,
1501 .p_class = P_LOCAL,
1502 .ptr = &sDefault.bAclCheckPermissions,
1503 .special = NULL,
1504 .enum_list = NULL,
1505 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1506 },
1507 {
1508 .label = "acl group control",
1509 .type = P_BOOL,
1510 .p_class = P_LOCAL,
1511 .ptr = &sDefault.bAclGroupControl,
1512 .special = NULL,
1513 .enum_list = NULL,
1514 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1515 },
1516 {
1517 .label = "acl map full control",
1518 .type = P_BOOL,
1519 .p_class = P_LOCAL,
1520 .ptr = &sDefault.bAclMapFullControl,
1521 .special = NULL,
1522 .enum_list = NULL,
1523 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1524 },
1525 {
1526 .label = "create mask",
1527 .type = P_OCTAL,
1528 .p_class = P_LOCAL,
1529 .ptr = &sDefault.iCreate_mask,
1530 .special = NULL,
1531 .enum_list = NULL,
1532 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1533 },
1534 {
1535 .label = "create mode",
1536 .type = P_OCTAL,
1537 .p_class = P_LOCAL,
1538 .ptr = &sDefault.iCreate_mask,
1539 .special = NULL,
1540 .enum_list = NULL,
1541 .flags = FLAG_HIDE,
1542 },
1543 {
1544 .label = "force create mode",
1545 .type = P_OCTAL,
1546 .p_class = P_LOCAL,
1547 .ptr = &sDefault.iCreate_force_mode,
1548 .special = NULL,
1549 .enum_list = NULL,
1550 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1551 },
1552 {
1553 .label = "security mask",
1554 .type = P_OCTAL,
1555 .p_class = P_LOCAL,
1556 .ptr = &sDefault.iSecurity_mask,
1557 .special = NULL,
1558 .enum_list = NULL,
1559 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1560 },
1561 {
1562 .label = "force security mode",
1563 .type = P_OCTAL,
1564 .p_class = P_LOCAL,
1565 .ptr = &sDefault.iSecurity_force_mode,
1566 .special = NULL,
1567 .enum_list = NULL,
1568 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1569 },
1570 {
1571 .label = "directory mask",
1572 .type = P_OCTAL,
1573 .p_class = P_LOCAL,
1574 .ptr = &sDefault.iDir_mask,
1575 .special = NULL,
1576 .enum_list = NULL,
1577 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1578 },
1579 {
1580 .label = "directory mode",
1581 .type = P_OCTAL,
1582 .p_class = P_LOCAL,
1583 .ptr = &sDefault.iDir_mask,
1584 .special = NULL,
1585 .enum_list = NULL,
1586 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1587 },
1588 {
1589 .label = "force directory mode",
1590 .type = P_OCTAL,
1591 .p_class = P_LOCAL,
1592 .ptr = &sDefault.iDir_force_mode,
1593 .special = NULL,
1594 .enum_list = NULL,
1595 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1596 },
1597 {
1598 .label = "directory security mask",
1599 .type = P_OCTAL,
1600 .p_class = P_LOCAL,
1601 .ptr = &sDefault.iDir_Security_mask,
1602 .special = NULL,
1603 .enum_list = NULL,
1604 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1605 },
1606 {
1607 .label = "force directory security mode",
1608 .type = P_OCTAL,
1609 .p_class = P_LOCAL,
1610 .ptr = &sDefault.iDir_Security_force_mode,
1611 .special = NULL,
1612 .enum_list = NULL,
1613 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1614 },
1615 {
1616 .label = "force unknown acl user",
1617 .type = P_BOOL,
1618 .p_class = P_LOCAL,
1619 .ptr = &sDefault.bForceUnknownAclUser,
1620 .special = NULL,
1621 .enum_list = NULL,
1622 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1623 },
1624 {
1625 .label = "inherit permissions",
1626 .type = P_BOOL,
1627 .p_class = P_LOCAL,
1628 .ptr = &sDefault.bInheritPerms,
1629 .special = NULL,
1630 .enum_list = NULL,
1631 .flags = FLAG_ADVANCED | FLAG_SHARE,
1632 },
1633 {
1634 .label = "inherit acls",
1635 .type = P_BOOL,
1636 .p_class = P_LOCAL,
1637 .ptr = &sDefault.bInheritACLS,
1638 .special = NULL,
1639 .enum_list = NULL,
1640 .flags = FLAG_ADVANCED | FLAG_SHARE,
1641 },
1642 {
1643 .label = "inherit owner",
1644 .type = P_BOOL,
1645 .p_class = P_LOCAL,
1646 .ptr = &sDefault.bInheritOwner,
1647 .special = NULL,
1648 .enum_list = NULL,
1649 .flags = FLAG_ADVANCED | FLAG_SHARE,
1650 },
1651 {
1652 .label = "guest only",
1653 .type = P_BOOL,
1654 .p_class = P_LOCAL,
1655 .ptr = &sDefault.bGuest_only,
1656 .special = NULL,
1657 .enum_list = NULL,
1658 .flags = FLAG_ADVANCED | FLAG_SHARE,
1659 },
1660 {
1661 .label = "only guest",
1662 .type = P_BOOL,
1663 .p_class = P_LOCAL,
1664 .ptr = &sDefault.bGuest_only,
1665 .special = NULL,
1666 .enum_list = NULL,
1667 .flags = FLAG_HIDE,
1668 },
1669 {
1670 .label = "administrative share",
1671 .type = P_BOOL,
1672 .p_class = P_LOCAL,
1673 .ptr = &sDefault.bAdministrative_share,
1674 .special = NULL,
1675 .enum_list = NULL,
1676 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1677 },
1678
1679 {
1680 .label = "guest ok",
1681 .type = P_BOOL,
1682 .p_class = P_LOCAL,
1683 .ptr = &sDefault.bGuest_ok,
1684 .special = NULL,
1685 .enum_list = NULL,
1686 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1687 },
1688 {
1689 .label = "public",
1690 .type = P_BOOL,
1691 .p_class = P_LOCAL,
1692 .ptr = &sDefault.bGuest_ok,
1693 .special = NULL,
1694 .enum_list = NULL,
1695 .flags = FLAG_HIDE,
1696 },
1697 {
1698 .label = "only user",
1699 .type = P_BOOL,
1700 .p_class = P_LOCAL,
1701 .ptr = &sDefault.bOnlyUser,
1702 .special = NULL,
1703 .enum_list = NULL,
1704 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1705 },
1706 {
1707 .label = "hosts allow",
1708 .type = P_LIST,
1709 .p_class = P_LOCAL,
1710 .ptr = &sDefault.szHostsallow,
1711 .special = NULL,
1712 .enum_list = NULL,
1713 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1714 },
1715 {
1716 .label = "allow hosts",
1717 .type = P_LIST,
1718 .p_class = P_LOCAL,
1719 .ptr = &sDefault.szHostsallow,
1720 .special = NULL,
1721 .enum_list = NULL,
1722 .flags = FLAG_HIDE,
1723 },
1724 {
1725 .label = "hosts deny",
1726 .type = P_LIST,
1727 .p_class = P_LOCAL,
1728 .ptr = &sDefault.szHostsdeny,
1729 .special = NULL,
1730 .enum_list = NULL,
1731 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1732 },
1733 {
1734 .label = "deny hosts",
1735 .type = P_LIST,
1736 .p_class = P_LOCAL,
1737 .ptr = &sDefault.szHostsdeny,
1738 .special = NULL,
1739 .enum_list = NULL,
1740 .flags = FLAG_HIDE,
1741 },
1742 {
1743 .label = "preload modules",
1744 .type = P_LIST,
1745 .p_class = P_GLOBAL,
1746 .ptr = &Globals.szPreloadModules,
1747 .special = NULL,
1748 .enum_list = NULL,
1749 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1750 },
1751 {
1752 .label = "use kerberos keytab",
1753 .type = P_BOOL,
1754 .p_class = P_GLOBAL,
1755 .ptr = &Globals.bUseKerberosKeytab,
1756 .special = NULL,
1757 .enum_list = NULL,
1758 .flags = FLAG_ADVANCED,
1759 },
1760
1761 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1762
1763 {
1764 .label = "log level",
1765 .type = P_STRING,
1766 .p_class = P_GLOBAL,
1767 .ptr = &Globals.szLogLevel,
1768 .special = handle_debug_list,
1769 .enum_list = NULL,
1770 .flags = FLAG_ADVANCED,
1771 },
1772 {
1773 .label = "debuglevel",
1774 .type = P_STRING,
1775 .p_class = P_GLOBAL,
1776 .ptr = &Globals.szLogLevel,
1777 .special = handle_debug_list,
1778 .enum_list = NULL,
1779 .flags = FLAG_HIDE,
1780 },
1781 {
1782 .label = "syslog",
1783 .type = P_INTEGER,
1784 .p_class = P_GLOBAL,
1785 .ptr = &Globals.syslog,
1786 .special = NULL,
1787 .enum_list = NULL,
1788 .flags = FLAG_ADVANCED,
1789 },
1790 {
1791 .label = "syslog only",
1792 .type = P_BOOL,
1793 .p_class = P_GLOBAL,
1794 .ptr = &Globals.bSyslogOnly,
1795 .special = NULL,
1796 .enum_list = NULL,
1797 .flags = FLAG_ADVANCED,
1798 },
1799 {
1800 .label = "log file",
1801 .type = P_STRING,
1802 .p_class = P_GLOBAL,
1803 .ptr = &Globals.szLogFile,
1804 .special = NULL,
1805 .enum_list = NULL,
1806 .flags = FLAG_ADVANCED,
1807 },
1808 {
1809 .label = "max log size",
1810 .type = P_INTEGER,
1811 .p_class = P_GLOBAL,
1812 .ptr = &Globals.max_log_size,
1813 .special = NULL,
1814 .enum_list = NULL,
1815 .flags = FLAG_ADVANCED,
1816 },
1817 {
1818 .label = "debug timestamp",
1819 .type = P_BOOL,
1820 .p_class = P_GLOBAL,
1821 .ptr = &Globals.bTimestampLogs,
1822 .special = NULL,
1823 .enum_list = NULL,
1824 .flags = FLAG_ADVANCED,
1825 },
1826 {
1827 .label = "timestamp logs",
1828 .type = P_BOOL,
1829 .p_class = P_GLOBAL,
1830 .ptr = &Globals.bTimestampLogs,
1831 .special = NULL,
1832 .enum_list = NULL,
1833 .flags = FLAG_ADVANCED,
1834 },
1835 {
1836 .label = "debug prefix timestamp",
1837 .type = P_BOOL,
1838 .p_class = P_GLOBAL,
1839 .ptr = &Globals.bDebugPrefixTimestamp,
1840 .special = NULL,
1841 .enum_list = NULL,
1842 .flags = FLAG_ADVANCED,
1843 },
1844 {
1845 .label = "debug hires timestamp",
1846 .type = P_BOOL,
1847 .p_class = P_GLOBAL,
1848 .ptr = &Globals.bDebugHiresTimestamp,
1849 .special = NULL,
1850 .enum_list = NULL,
1851 .flags = FLAG_ADVANCED,
1852 },
1853 {
1854 .label = "debug pid",
1855 .type = P_BOOL,
1856 .p_class = P_GLOBAL,
1857 .ptr = &Globals.bDebugPid,
1858 .special = NULL,
1859 .enum_list = NULL,
1860 .flags = FLAG_ADVANCED,
1861 },
1862 {
1863 .label = "debug uid",
1864 .type = P_BOOL,
1865 .p_class = P_GLOBAL,
1866 .ptr = &Globals.bDebugUid,
1867 .special = NULL,
1868 .enum_list = NULL,
1869 .flags = FLAG_ADVANCED,
1870 },
1871 {
1872 .label = "debug class",
1873 .type = P_BOOL,
1874 .p_class = P_GLOBAL,
1875 .ptr = &Globals.bDebugClass,
1876 .special = NULL,
1877 .enum_list = NULL,
1878 .flags = FLAG_ADVANCED,
1879 },
1880 {
1881 .label = "enable core files",
1882 .type = P_BOOL,
1883 .p_class = P_GLOBAL,
1884 .ptr = &Globals.bEnableCoreFiles,
1885 .special = NULL,
1886 .enum_list = NULL,
1887 .flags = FLAG_ADVANCED,
1888 },
1889
1890 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1891
1892 {
1893 .label = "allocation roundup size",
1894 .type = P_INTEGER,
1895 .p_class = P_LOCAL,
1896 .ptr = &sDefault.iallocation_roundup_size,
1897 .special = NULL,
1898 .enum_list = NULL,
1899 .flags = FLAG_ADVANCED,
1900 },
1901 {
1902 .label = "aio read size",
1903 .type = P_INTEGER,
1904 .p_class = P_LOCAL,
1905 .ptr = &sDefault.iAioReadSize,
1906 .special = NULL,
1907 .enum_list = NULL,
1908 .flags = FLAG_ADVANCED,
1909 },
1910 {
1911 .label = "aio write size",
1912 .type = P_INTEGER,
1913 .p_class = P_LOCAL,
1914 .ptr = &sDefault.iAioWriteSize,
1915 .special = NULL,
1916 .enum_list = NULL,
1917 .flags = FLAG_ADVANCED,
1918 },
1919 {
1920 .label = "aio write behind",
1921 .type = P_STRING,
1922 .p_class = P_LOCAL,
1923 .ptr = &sDefault.szAioWriteBehind,
1924 .special = NULL,
1925 .enum_list = NULL,
1926 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1927 },
1928 {
1929 .label = "smb ports",
1930 .type = P_STRING,
1931 .p_class = P_GLOBAL,
1932 .ptr = &Globals.smb_ports,
1933 .special = NULL,
1934 .enum_list = NULL,
1935 .flags = FLAG_ADVANCED,
1936 },
1937 {
1938 .label = "large readwrite",
1939 .type = P_BOOL,
1940 .p_class = P_GLOBAL,
1941 .ptr = &Globals.bLargeReadwrite,
1942 .special = NULL,
1943 .enum_list = NULL,
1944 .flags = FLAG_ADVANCED,
1945 },
1946 {
1947 .label = "max protocol",
1948 .type = P_ENUM,
1949 .p_class = P_GLOBAL,
1950 .ptr = &Globals.maxprotocol,
1951 .special = NULL,
1952 .enum_list = enum_protocol,
1953 .flags = FLAG_ADVANCED,
1954 },
1955 {
1956 .label = "protocol",
1957 .type = P_ENUM,
1958 .p_class = P_GLOBAL,
1959 .ptr = &Globals.maxprotocol,
1960 .special = NULL,
1961 .enum_list = enum_protocol,
1962 .flags = FLAG_ADVANCED,
1963 },
1964 {
1965 .label = "min protocol",
1966 .type = P_ENUM,
1967 .p_class = P_GLOBAL,
1968 .ptr = &Globals.minprotocol,
1969 .special = NULL,
1970 .enum_list = enum_protocol,
1971 .flags = FLAG_ADVANCED,
1972 },
1973 {
1974 .label = "min receivefile size",
1975 .type = P_INTEGER,
1976 .p_class = P_GLOBAL,
1977 .ptr = &Globals.iminreceivefile,
1978 .special = NULL,
1979 .enum_list = NULL,
1980 .flags = FLAG_ADVANCED,
1981 },
1982 {
1983 .label = "read raw",
1984 .type = P_BOOL,
1985 .p_class = P_GLOBAL,
1986 .ptr = &Globals.bReadRaw,
1987 .special = NULL,
1988 .enum_list = NULL,
1989 .flags = FLAG_ADVANCED,
1990 },
1991 {
1992 .label = "write raw",
1993 .type = P_BOOL,
1994 .p_class = P_GLOBAL,
1995 .ptr = &Globals.bWriteRaw,
1996 .special = NULL,
1997 .enum_list = NULL,
1998 .flags = FLAG_ADVANCED,
1999 },
2000 {
2001 .label = "disable netbios",
2002 .type = P_BOOL,
2003 .p_class = P_GLOBAL,
2004 .ptr = &Globals.bDisableNetbios,
2005 .special = NULL,
2006 .enum_list = NULL,
2007 .flags = FLAG_ADVANCED,
2008 },
2009 {
2010 .label = "reset on zero vc",
2011 .type = P_BOOL,
2012 .p_class = P_GLOBAL,
2013 .ptr = &Globals.bResetOnZeroVC,
2014 .special = NULL,
2015 .enum_list = NULL,
2016 .flags = FLAG_ADVANCED,
2017 },
2018 {
2019 .label = "acl compatibility",
2020 .type = P_ENUM,
2021 .p_class = P_GLOBAL,
2022 .ptr = &Globals.iAclCompat,
2023 .special = NULL,
2024 .enum_list = enum_acl_compat_vals,
2025 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2026 },
2027 {
2028 .label = "defer sharing violations",
2029 .type = P_BOOL,
2030 .p_class = P_GLOBAL,
2031 .ptr = &Globals.bDeferSharingViolations,
2032 .special = NULL,
2033 .enum_list = NULL,
2034 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2035 },
2036 {
2037 .label = "ea support",
2038 .type = P_BOOL,
2039 .p_class = P_LOCAL,
2040 .ptr = &sDefault.bEASupport,
2041 .special = NULL,
2042 .enum_list = NULL,
2043 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2044 },
2045 {
2046 .label = "nt acl support",
2047 .type = P_BOOL,
2048 .p_class = P_LOCAL,
2049 .ptr = &sDefault.bNTAclSupport,
2050 .special = NULL,
2051 .enum_list = NULL,
2052 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2053 },
2054 {
2055 .label = "nt pipe support",
2056 .type = P_BOOL,
2057 .p_class = P_GLOBAL,
2058 .ptr = &Globals.bNTPipeSupport,
2059 .special = NULL,
2060 .enum_list = NULL,
2061 .flags = FLAG_ADVANCED,
2062 },
2063 {
2064 .label = "nt status support",
2065 .type = P_BOOL,
2066 .p_class = P_GLOBAL,
2067 .ptr = &Globals.bNTStatusSupport,
2068 .special = NULL,
2069 .enum_list = NULL,
2070 .flags = FLAG_ADVANCED,
2071 },
2072 {
2073 .label = "profile acls",
2074 .type = P_BOOL,
2075 .p_class = P_LOCAL,
2076 .ptr = &sDefault.bProfileAcls,
2077 .special = NULL,
2078 .enum_list = NULL,
2079 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2080 },
2081 {
2082 .label = "announce version",
2083 .type = P_STRING,
2084 .p_class = P_GLOBAL,
2085 .ptr = &Globals.szAnnounceVersion,
2086 .special = NULL,
2087 .enum_list = NULL,
2088 .flags = FLAG_ADVANCED,
2089 },
2090 {
2091 .label = "announce as",
2092 .type = P_ENUM,
2093 .p_class = P_GLOBAL,
2094 .ptr = &Globals.announce_as,
2095 .special = NULL,
2096 .enum_list = enum_announce_as,
2097 .flags = FLAG_ADVANCED,
2098 },
2099 {
2100 .label = "map acl inherit",
2101 .type = P_BOOL,
2102 .p_class = P_LOCAL,
2103 .ptr = &sDefault.bMap_acl_inherit,
2104 .special = NULL,
2105 .enum_list = NULL,
2106 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2107 },
2108 {
2109 .label = "afs share",
2110 .type = P_BOOL,
2111 .p_class = P_LOCAL,
2112 .ptr = &sDefault.bAfs_Share,
2113 .special = NULL,
2114 .enum_list = NULL,
2115 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2116 },
2117 {
2118 .label = "max mux",
2119 .type = P_INTEGER,
2120 .p_class = P_GLOBAL,
2121 .ptr = &Globals.max_mux,
2122 .special = NULL,
2123 .enum_list = NULL,
2124 .flags = FLAG_ADVANCED,
2125 },
2126 {
2127 .label = "max xmit",
2128 .type = P_INTEGER,
2129 .p_class = P_GLOBAL,
2130 .ptr = &Globals.max_xmit,
2131 .special = NULL,
2132 .enum_list = NULL,
2133 .flags = FLAG_ADVANCED,
2134 },
2135 {
2136 .label = "name resolve order",
2137 .type = P_STRING,
2138 .p_class = P_GLOBAL,
2139 .ptr = &Globals.szNameResolveOrder,
2140 .special = NULL,
2141 .enum_list = NULL,
2142 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2143 },
2144 {
2145 .label = "max ttl",
2146 .type = P_INTEGER,
2147 .p_class = P_GLOBAL,
2148 .ptr = &Globals.max_ttl,
2149 .special = NULL,
2150 .enum_list = NULL,
2151 .flags = FLAG_ADVANCED,
2152 },
2153 {
2154 .label = "max wins ttl",
2155 .type = P_INTEGER,
2156 .p_class = P_GLOBAL,
2157 .ptr = &Globals.max_wins_ttl,
2158 .special = NULL,
2159 .enum_list = NULL,
2160 .flags = FLAG_ADVANCED,
2161 },
2162 {
2163 .label = "min wins ttl",
2164 .type = P_INTEGER,
2165 .p_class = P_GLOBAL,
2166 .ptr = &Globals.min_wins_ttl,
2167 .special = NULL,
2168 .enum_list = NULL,
2169 .flags = FLAG_ADVANCED,
2170 },
2171 {
2172 .label = "time server",
2173 .type = P_BOOL,
2174 .p_class = P_GLOBAL,
2175 .ptr = &Globals.bTimeServer,
2176 .special = NULL,
2177 .enum_list = NULL,
2178 .flags = FLAG_ADVANCED,
2179 },
2180 {
2181 .label = "unix extensions",
2182 .type = P_BOOL,
2183 .p_class = P_GLOBAL,
2184 .ptr = &Globals.bUnixExtensions,
2185 .special = NULL,
2186 .enum_list = NULL,
2187 .flags = FLAG_ADVANCED,
2188 },
2189 {
2190 .label = "use spnego",
2191 .type = P_BOOL,
2192 .p_class = P_GLOBAL,
2193 .ptr = &Globals.bUseSpnego,
2194 .special = NULL,
2195 .enum_list = NULL,
2196 .flags = FLAG_ADVANCED,
2197 },
2198 {
2199 .label = "client signing",
2200 .type = P_ENUM,
2201 .p_class = P_GLOBAL,
2202 .ptr = &Globals.client_signing,
2203 .special = NULL,
2204 .enum_list = enum_smb_signing_vals,
2205 .flags = FLAG_ADVANCED,
2206 },
2207 {
2208 .label = "server signing",
2209 .type = P_ENUM,
2210 .p_class = P_GLOBAL,
2211 .ptr = &Globals.server_signing,
2212 .special = NULL,
2213 .enum_list = enum_smb_signing_vals,
2214 .flags = FLAG_ADVANCED,
2215 },
2216 {
2217 .label = "smb encrypt",
2218 .type = P_ENUM,
2219 .p_class = P_LOCAL,
2220 .ptr = &sDefault.ismb_encrypt,
2221 .special = NULL,
2222 .enum_list = enum_smb_signing_vals,
2223 .flags = FLAG_ADVANCED,
2224 },
2225 {
2226 .label = "client use spnego",
2227 .type = P_BOOL,
2228 .p_class = P_GLOBAL,
2229 .ptr = &Globals.bClientUseSpnego,
2230 .special = NULL,
2231 .enum_list = NULL,
2232 .flags = FLAG_ADVANCED,
2233 },
2234 {
2235 .label = "client ldap sasl wrapping",
2236 .type = P_ENUM,
2237 .p_class = P_GLOBAL,
2238 .ptr = &Globals.client_ldap_sasl_wrapping,
2239 .special = NULL,
2240 .enum_list = enum_ldap_sasl_wrapping,
2241 .flags = FLAG_ADVANCED,
2242 },
2243 {
2244 .label = "enable asu support",
2245 .type = P_BOOL,
2246 .p_class = P_GLOBAL,
2247 .ptr = &Globals.bASUSupport,
2248 .special = NULL,
2249 .enum_list = NULL,
2250 .flags = FLAG_ADVANCED,
2251 },
2252 {
2253 .label = "svcctl list",
2254 .type = P_LIST,
2255 .p_class = P_GLOBAL,
2256 .ptr = &Globals.szServicesList,
2257 .special = NULL,
2258 .enum_list = NULL,
2259 .flags = FLAG_ADVANCED,
2260 },
2261
2262 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2263
2264 {
2265 .label = "block size",
2266 .type = P_INTEGER,
2267 .p_class = P_LOCAL,
2268 .ptr = &sDefault.iBlock_size,
2269 .special = NULL,
2270 .enum_list = NULL,
2271 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2272 },
2273 {
2274 .label = "deadtime",
2275 .type = P_INTEGER,
2276 .p_class = P_GLOBAL,
2277 .ptr = &Globals.deadtime,
2278 .special = NULL,
2279 .enum_list = NULL,
2280 .flags = FLAG_ADVANCED,
2281 },
2282 {
2283 .label = "getwd cache",
2284 .type = P_BOOL,
2285 .p_class = P_GLOBAL,
2286 .ptr = &Globals.getwd_cache,
2287 .special = NULL,
2288 .enum_list = NULL,
2289 .flags = FLAG_ADVANCED,
2290 },
2291 {
2292 .label = "keepalive",
2293 .type = P_INTEGER,
2294 .p_class = P_GLOBAL,
2295 .ptr = &Globals.iKeepalive,
2296 .special = NULL,
2297 .enum_list = NULL,
2298 .flags = FLAG_ADVANCED,
2299 },
2300 {
2301 .label = "change notify",
2302 .type = P_BOOL,
2303 .p_class = P_LOCAL,
2304 .ptr = &sDefault.bChangeNotify,
2305 .special = NULL,
2306 .enum_list = NULL,
2307 .flags = FLAG_ADVANCED | FLAG_SHARE,
2308 },
2309 {
2310 .label = "directory name cache size",
2311 .type = P_INTEGER,
2312 .p_class = P_LOCAL,
2313 .ptr = &sDefault.iDirectoryNameCacheSize,
2314 .special = NULL,
2315 .enum_list = NULL,
2316 .flags = FLAG_ADVANCED | FLAG_SHARE,
2317 },
2318 {
2319 .label = "kernel change notify",
2320 .type = P_BOOL,
2321 .p_class = P_LOCAL,
2322 .ptr = &sDefault.bKernelChangeNotify,
2323 .special = NULL,
2324 .enum_list = NULL,
2325 .flags = FLAG_ADVANCED | FLAG_SHARE,
2326 },
2327 {
2328 .label = "lpq cache time",
2329 .type = P_INTEGER,
2330 .p_class = P_GLOBAL,
2331 .ptr = &Globals.lpqcachetime,
2332 .special = NULL,
2333 .enum_list = NULL,
2334 .flags = FLAG_ADVANCED,
2335 },
2336 {
2337 .label = "max smbd processes",
2338 .type = P_INTEGER,
2339 .p_class = P_GLOBAL,
2340 .ptr = &Globals.iMaxSmbdProcesses,
2341 .special = NULL,
2342 .enum_list = NULL,
2343 .flags = FLAG_ADVANCED,
2344 },
2345 {
2346 .label = "max connections",
2347 .type = P_INTEGER,
2348 .p_class = P_LOCAL,
2349 .ptr = &sDefault.iMaxConnections,
2350 .special = NULL,
2351 .enum_list = NULL,
2352 .flags = FLAG_ADVANCED | FLAG_SHARE,
2353 },
2354 {
2355 .label = "paranoid server security",
2356 .type = P_BOOL,
2357 .p_class = P_GLOBAL,
2358 .ptr = &Globals.paranoid_server_security,
2359 .special = NULL,
2360 .enum_list = NULL,
2361 .flags = FLAG_ADVANCED,
2362 },
2363 {
2364 .label = "max disk size",
2365 .type = P_INTEGER,
2366 .p_class = P_GLOBAL,
2367 .ptr = &Globals.maxdisksize,
2368 .special = NULL,
2369 .enum_list = NULL,
2370 .flags = FLAG_ADVANCED,
2371 },
2372 {
2373 .label = "max open files",
2374 .type = P_INTEGER,
2375 .p_class = P_GLOBAL,
2376 .ptr = &Globals.max_open_files,
2377 .special = NULL,
2378 .enum_list = NULL,
2379 .flags = FLAG_ADVANCED,
2380 },
2381 {
2382 .label = "min print space",
2383 .type = P_INTEGER,
2384 .p_class = P_LOCAL,
2385 .ptr = &sDefault.iMinPrintSpace,
2386 .special = NULL,
2387 .enum_list = NULL,
2388 .flags = FLAG_ADVANCED | FLAG_PRINT,
2389 },
2390 {
2391 .label = "socket options",
2392 .type = P_STRING,
2393 .p_class = P_GLOBAL,
2394 .ptr = &Globals.szSocketOptions,
2395 .special = NULL,
2396 .enum_list = NULL,
2397 .flags = FLAG_ADVANCED,
2398 },
2399 {
2400 .label = "strict allocate",
2401 .type = P_BOOL,
2402 .p_class = P_LOCAL,
2403 .ptr = &sDefault.bStrictAllocate,
2404 .special = NULL,
2405 .enum_list = NULL,
2406 .flags = FLAG_ADVANCED | FLAG_SHARE,
2407 },
2408 {
2409 .label = "strict sync",
2410 .type = P_BOOL,
2411 .p_class = P_LOCAL,
2412 .ptr = &sDefault.bStrictSync,
2413 .special = NULL,
2414 .enum_list = NULL,
2415 .flags = FLAG_ADVANCED | FLAG_SHARE,
2416 },
2417 {
2418 .label = "sync always",
2419 .type = P_BOOL,
2420 .p_class = P_LOCAL,
2421 .ptr = &sDefault.bSyncAlways,
2422 .special = NULL,
2423 .enum_list = NULL,
2424 .flags = FLAG_ADVANCED | FLAG_SHARE,
2425 },
2426 {
2427 .label = "use mmap",
2428 .type = P_BOOL,
2429 .p_class = P_GLOBAL,
2430 .ptr = &Globals.bUseMmap,
2431 .special = NULL,
2432 .enum_list = NULL,
2433 .flags = FLAG_ADVANCED,
2434 },
2435 {
2436 .label = "use sendfile",
2437 .type = P_BOOL,
2438 .p_class = P_LOCAL,
2439 .ptr = &sDefault.bUseSendfile,
2440 .special = NULL,
2441 .enum_list = NULL,
2442 .flags = FLAG_ADVANCED | FLAG_SHARE,
2443 },
2444 {
2445 .label = "hostname lookups",
2446 .type = P_BOOL,
2447 .p_class = P_GLOBAL,
2448 .ptr = &Globals.bHostnameLookups,
2449 .special = NULL,
2450 .enum_list = NULL,
2451 .flags = FLAG_ADVANCED,
2452 },
2453 {
2454 .label = "write cache size",
2455 .type = P_INTEGER,
2456 .p_class = P_LOCAL,
2457 .ptr = &sDefault.iWriteCacheSize,
2458 .special = NULL,
2459 .enum_list = NULL,
2460 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2461 },
2462 {
2463 .label = "name cache timeout",
2464 .type = P_INTEGER,
2465 .p_class = P_GLOBAL,
2466 .ptr = &Globals.name_cache_timeout,
2467 .special = NULL,
2468 .enum_list = NULL,
2469 .flags = FLAG_ADVANCED,
2470 },
2471 {
2472 .label = "ctdbd socket",
2473 .type = P_STRING,
2474 .p_class = P_GLOBAL,
2475 .ptr = &Globals.ctdbdSocket,
2476 .special = NULL,
2477 .enum_list = NULL,
2478 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2479 },
2480 {
2481 .label = "cluster addresses",
2482 .type = P_LIST,
2483 .p_class = P_GLOBAL,
2484 .ptr = &Globals.szClusterAddresses,
2485 .special = NULL,
2486 .enum_list = NULL,
2487 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2488 },
2489 {
2490 .label = "clustering",
2491 .type = P_BOOL,
2492 .p_class = P_GLOBAL,
2493 .ptr = &Globals.clustering,
2494 .special = NULL,
2495 .enum_list = NULL,
2496 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2497 },
2498
2499 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2500
2501 {
2502 .label = "max reported print jobs",
2503 .type = P_INTEGER,
2504 .p_class = P_LOCAL,
2505 .ptr = &sDefault.iMaxReportedPrintJobs,
2506 .special = NULL,
2507 .enum_list = NULL,
2508 .flags = FLAG_ADVANCED | FLAG_PRINT,
2509 },
2510 {
2511 .label = "max print jobs",
2512 .type = P_INTEGER,
2513 .p_class = P_LOCAL,
2514 .ptr = &sDefault.iMaxPrintJobs,
2515 .special = NULL,
2516 .enum_list = NULL,
2517 .flags = FLAG_ADVANCED | FLAG_PRINT,
2518 },
2519 {
2520 .label = "load printers",
2521 .type = P_BOOL,
2522 .p_class = P_GLOBAL,
2523 .ptr = &Globals.bLoadPrinters,
2524 .special = NULL,
2525 .enum_list = NULL,
2526 .flags = FLAG_ADVANCED | FLAG_PRINT,
2527 },
2528 {
2529 .label = "printcap cache time",
2530 .type = P_INTEGER,
2531 .p_class = P_GLOBAL,
2532 .ptr = &Globals.PrintcapCacheTime,
2533 .special = NULL,
2534 .enum_list = NULL,
2535 .flags = FLAG_ADVANCED | FLAG_PRINT,
2536 },
2537 {
2538 .label = "printcap name",
2539 .type = P_STRING,
2540 .p_class = P_GLOBAL,
2541 .ptr = &Globals.szPrintcapname,
2542 .special = NULL,
2543 .enum_list = NULL,
2544 .flags = FLAG_ADVANCED | FLAG_PRINT,
2545 },
2546 {
2547 .label = "printcap",
2548 .type = P_STRING,
2549 .p_class = P_GLOBAL,
2550 .ptr = &Globals.szPrintcapname,
2551 .special = NULL,
2552 .enum_list = NULL,
2553 .flags = FLAG_HIDE,
2554 },
2555 {
2556 .label = "printable",
2557 .type = P_BOOL,
2558 .p_class = P_LOCAL,
2559 .ptr = &sDefault.bPrint_ok,
2560 .special = NULL,
2561 .enum_list = NULL,
2562 .flags = FLAG_ADVANCED | FLAG_PRINT,
2563 },
2564 {
2565 .label = "print ok",
2566 .type = P_BOOL,
2567 .p_class = P_LOCAL,
2568 .ptr = &sDefault.bPrint_ok,
2569 .special = NULL,
2570 .enum_list = NULL,
2571 .flags = FLAG_HIDE,
2572 },
2573 {
2574 .label = "printing",
2575 .type = P_ENUM,
2576 .p_class = P_LOCAL,
2577 .ptr = &sDefault.iPrinting,
2578 .special = handle_printing,
2579 .enum_list = enum_printing,
2580 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2581 },
2582 {
2583 .label = "cups options",
2584 .type = P_STRING,
2585 .p_class = P_LOCAL,
2586 .ptr = &sDefault.szCupsOptions,
2587 .special = NULL,
2588 .enum_list = NULL,
2589 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2590 },
2591 {
2592 .label = "cups server",
2593 .type = P_STRING,
2594 .p_class = P_GLOBAL,
2595 .ptr = &Globals.szCupsServer,
2596 .special = NULL,
2597 .enum_list = NULL,
2598 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2599 },
2600 {
2601 .label = "cups connection timeout",
2602 .type = P_INTEGER,
2603 .p_class = P_GLOBAL,
2604 .ptr = &Globals.cups_connection_timeout,
2605 .special = NULL,
2606 .enum_list = NULL,
2607 .flags = FLAG_ADVANCED,
2608 },
2609 {
2610 .label = "iprint server",
2611 .type = P_STRING,
2612 .p_class = P_GLOBAL,
2613 .ptr = &Globals.szIPrintServer,
2614 .special = NULL,
2615 .enum_list = NULL,
2616 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2617 },
2618 {
2619 .label = "print command",
2620 .type = P_STRING,
2621 .p_class = P_LOCAL,
2622 .ptr = &sDefault.szPrintcommand,
2623 .special = NULL,
2624 .enum_list = NULL,
2625 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2626 },
2627 {
2628 .label = "disable spoolss",
2629 .type = P_BOOL,
2630 .p_class = P_GLOBAL,
2631 .ptr = &Globals.bDisableSpoolss,
2632 .special = NULL,
2633 .enum_list = NULL,
2634 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2635 },
2636 {
2637 .label = "enable spoolss",
2638 .type = P_BOOLREV,
2639 .p_class = P_GLOBAL,
2640 .ptr = &Globals.bDisableSpoolss,
2641 .special = NULL,
2642 .enum_list = NULL,
2643 .flags = FLAG_HIDE,
2644 },
2645 {
2646 .label = "lpq command",
2647 .type = P_STRING,
2648 .p_class = P_LOCAL,
2649 .ptr = &sDefault.szLpqcommand,
2650 .special = NULL,
2651 .enum_list = NULL,
2652 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2653 },
2654 {
2655 .label = "lprm command",
2656 .type = P_STRING,
2657 .p_class = P_LOCAL,
2658 .ptr = &sDefault.szLprmcommand,
2659 .special = NULL,
2660 .enum_list = NULL,
2661 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2662 },
2663 {
2664 .label = "lppause command",
2665 .type = P_STRING,
2666 .p_class = P_LOCAL,
2667 .ptr = &sDefault.szLppausecommand,
2668 .special = NULL,
2669 .enum_list = NULL,
2670 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2671 },
2672 {
2673 .label = "lpresume command",
2674 .type = P_STRING,
2675 .p_class = P_LOCAL,
2676 .ptr = &sDefault.szLpresumecommand,
2677 .special = NULL,
2678 .enum_list = NULL,
2679 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2680 },
2681 {
2682 .label = "queuepause command",
2683 .type = P_STRING,
2684 .p_class = P_LOCAL,
2685 .ptr = &sDefault.szQueuepausecommand,
2686 .special = NULL,
2687 .enum_list = NULL,
2688 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2689 },
2690 {
2691 .label = "queueresume command",
2692 .type = P_STRING,
2693 .p_class = P_LOCAL,
2694 .ptr = &sDefault.szQueueresumecommand,
2695 .special = NULL,
2696 .enum_list = NULL,
2697 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2698 },
2699 {
2700 .label = "addport command",
2701 .type = P_STRING,
2702 .p_class = P_GLOBAL,
2703 .ptr = &Globals.szAddPortCommand,
2704 .special = NULL,
2705 .enum_list = NULL,
2706 .flags = FLAG_ADVANCED,
2707 },
2708 {
2709 .label = "enumports command",
2710 .type = P_STRING,
2711 .p_class = P_GLOBAL,
2712 .ptr = &Globals.szEnumPortsCommand,
2713 .special = NULL,
2714 .enum_list = NULL,
2715 .flags = FLAG_ADVANCED,
2716 },
2717 {
2718 .label = "addprinter command",
2719 .type = P_STRING,
2720 .p_class = P_GLOBAL,
2721 .ptr = &Globals.szAddPrinterCommand,
2722 .special = NULL,
2723 .enum_list = NULL,
2724 .flags = FLAG_ADVANCED,
2725 },
2726 {
2727 .label = "deleteprinter command",
2728 .type = P_STRING,
2729 .p_class = P_GLOBAL,
2730 .ptr = &Globals.szDeletePrinterCommand,
2731 .special = NULL,
2732 .enum_list = NULL,
2733 .flags = FLAG_ADVANCED,
2734 },
2735 {
2736 .label = "show add printer wizard",
2737 .type = P_BOOL,
2738 .p_class = P_GLOBAL,
2739 .ptr = &Globals.bMsAddPrinterWizard,
2740 .special = NULL,
2741 .enum_list = NULL,
2742 .flags = FLAG_ADVANCED,
2743 },
2744 {
2745 .label = "os2 driver map",
2746 .type = P_STRING,
2747 .p_class = P_GLOBAL,
2748 .ptr = &Globals.szOs2DriverMap,
2749 .special = NULL,
2750 .enum_list = NULL,
2751 .flags = FLAG_ADVANCED,
2752 },
2753
2754 {
2755 .label = "printer name",
2756 .type = P_STRING,
2757 .p_class = P_LOCAL,
2758 .ptr = &sDefault.szPrintername,
2759 .special = NULL,
2760 .enum_list = NULL,
2761 .flags = FLAG_ADVANCED | FLAG_PRINT,
2762 },
2763 {
2764 .label = "printer",
2765 .type = P_STRING,
2766 .p_class = P_LOCAL,
2767 .ptr = &sDefault.szPrintername,
2768 .special = NULL,
2769 .enum_list = NULL,
2770 .flags = FLAG_HIDE,
2771 },
2772 {
2773 .label = "use client driver",
2774 .type = P_BOOL,
2775 .p_class = P_LOCAL,
2776 .ptr = &sDefault.bUseClientDriver,
2777 .special = NULL,
2778 .enum_list = NULL,
2779 .flags = FLAG_ADVANCED | FLAG_PRINT,
2780 },
2781 {
2782 .label = "default devmode",
2783 .type = P_BOOL,
2784 .p_class = P_LOCAL,
2785 .ptr = &sDefault.bDefaultDevmode,
2786 .special = NULL,
2787 .enum_list = NULL,
2788 .flags = FLAG_ADVANCED | FLAG_PRINT,
2789 },
2790 {
2791 .label = "force printername",
2792 .type = P_BOOL,
2793 .p_class = P_LOCAL,
2794 .ptr = &sDefault.bForcePrintername,
2795 .special = NULL,
2796 .enum_list = NULL,
2797 .flags = FLAG_ADVANCED | FLAG_PRINT,
2798 },
2799 {
2800 .label = "printjob username",
2801 .type = P_STRING,
2802 .p_class = P_LOCAL,
2803 .ptr = &sDefault.szPrintjobUsername,
2804 .special = NULL,
2805 .enum_list = NULL,
2806 .flags = FLAG_ADVANCED | FLAG_PRINT,
2807 },
2808
2809 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2810
2811 {
2812 .label = "mangling method",
2813 .type = P_STRING,
2814 .p_class = P_GLOBAL,
2815 .ptr = &Globals.szManglingMethod,
2816 .special = NULL,
2817 .enum_list = NULL,
2818 .flags = FLAG_ADVANCED,
2819 },
2820 {
2821 .label = "mangle prefix",
2822 .type = P_INTEGER,
2823 .p_class = P_GLOBAL,
2824 .ptr = &Globals.mangle_prefix,
2825 .special = NULL,
2826 .enum_list = NULL,
2827 .flags = FLAG_ADVANCED,
2828 },
2829
2830 {
2831 .label = "default case",
2832 .type = P_ENUM,
2833 .p_class = P_LOCAL,
2834 .ptr = &sDefault.iDefaultCase,
2835 .special = NULL,
2836 .enum_list = enum_case,
2837 .flags = FLAG_ADVANCED | FLAG_SHARE,
2838 },
2839 {
2840 .label = "case sensitive",
2841 .type = P_ENUM,
2842 .p_class = P_LOCAL,
2843 .ptr = &sDefault.iCaseSensitive,
2844 .special = NULL,
2845 .enum_list = enum_bool_auto,
2846 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2847 },
2848 {
2849 .label = "casesignames",
2850 .type = P_ENUM,
2851 .p_class = P_LOCAL,
2852 .ptr = &sDefault.iCaseSensitive,
2853 .special = NULL,
2854 .enum_list = enum_bool_auto,
2855 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2856 },
2857 {
2858 .label = "preserve case",
2859 .type = P_BOOL,
2860 .p_class = P_LOCAL,
2861 .ptr = &sDefault.bCasePreserve,
2862 .special = NULL,
2863 .enum_list = NULL,
2864 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2865 },
2866 {
2867 .label = "short preserve case",
2868 .type = P_BOOL,
2869 .p_class = P_LOCAL,
2870 .ptr = &sDefault.bShortCasePreserve,
2871 .special = NULL,
2872 .enum_list = NULL,
2873 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2874 },
2875 {
2876 .label = "mangling char",
2877 .type = P_CHAR,
2878 .p_class = P_LOCAL,
2879 .ptr = &sDefault.magic_char,
2880 .special = NULL,
2881 .enum_list = NULL,
2882 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2883 },
2884 {
2885 .label = "hide dot files",
2886 .type = P_BOOL,
2887 .p_class = P_LOCAL,
2888 .ptr = &sDefault.bHideDotFiles,
2889 .special = NULL,
2890 .enum_list = NULL,
2891 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2892 },
2893 {
2894 .label = "hide special files",
2895 .type = P_BOOL,
2896 .p_class = P_LOCAL,
2897 .ptr = &sDefault.bHideSpecialFiles,
2898 .special = NULL,
2899 .enum_list = NULL,
2900 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2901 },
2902 {
2903 .label = "hide unreadable",
2904 .type = P_BOOL,
2905 .p_class = P_LOCAL,
2906 .ptr = &sDefault.bHideUnReadable,
2907 .special = NULL,
2908 .enum_list = NULL,
2909 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2910 },
2911 {
2912 .label = "hide unwriteable files",
2913 .type = P_BOOL,
2914 .p_class = P_LOCAL,
2915 .ptr = &sDefault.bHideUnWriteableFiles,
2916 .special = NULL,
2917 .enum_list = NULL,
2918 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2919 },
2920 {
2921 .label = "delete veto files",
2922 .type = P_BOOL,
2923 .p_class = P_LOCAL,
2924 .ptr = &sDefault.bDeleteVetoFiles,
2925 .special = NULL,
2926 .enum_list = NULL,
2927 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2928 },
2929 {
2930 .label = "veto files",
2931 .type = P_STRING,
2932 .p_class = P_LOCAL,
2933 .ptr = &sDefault.szVetoFiles,
2934 .special = NULL,
2935 .enum_list = NULL,
2936 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2937 },
2938 {
2939 .label = "hide files",
2940 .type = P_STRING,
2941 .p_class = P_LOCAL,
2942 .ptr = &sDefault.szHideFiles,
2943 .special = NULL,
2944 .enum_list = NULL,
2945 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2946 },
2947 {
2948 .label = "veto oplock files",
2949 .type = P_STRING,
2950 .p_class = P_LOCAL,
2951 .ptr = &sDefault.szVetoOplockFiles,
2952 .special = NULL,
2953 .enum_list = NULL,
2954 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2955 },
2956 {
2957 .label = "map archive",
2958 .type = P_BOOL,
2959 .p_class = P_LOCAL,
2960 .ptr = &sDefault.bMap_archive,
2961 .special = NULL,
2962 .enum_list = NULL,
2963 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2964 },
2965 {
2966 .label = "map hidden",
2967 .type = P_BOOL,
2968 .p_class = P_LOCAL,
2969 .ptr = &sDefault.bMap_hidden,
2970 .special = NULL,
2971 .enum_list = NULL,
2972 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2973 },
2974 {
2975 .label = "map system",
2976 .type = P_BOOL,
2977 .p_class = P_LOCAL,
2978 .ptr = &sDefault.bMap_system,
2979 .special = NULL,
2980 .enum_list = NULL,
2981 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2982 },
2983 {
2984 .label = "map readonly",
2985 .type = P_ENUM,
2986 .p_class = P_LOCAL,
2987 .ptr = &sDefault.iMap_readonly,
2988 .special = NULL,
2989 .enum_list = enum_map_readonly,
2990 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2991 },
2992 {
2993 .label = "mangled names",
2994 .type = P_BOOL,
2995 .p_class = P_LOCAL,
2996 .ptr = &sDefault.bMangledNames,
2997 .special = NULL,
2998 .enum_list = NULL,
2999 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3000 },
3001 {
3002 .label = "max stat cache size",
3003 .type = P_INTEGER,
3004 .p_class = P_GLOBAL,
3005 .ptr = &Globals.iMaxStatCacheSize,
3006 .special = NULL,
3007 .enum_list = NULL,
3008 .flags = FLAG_ADVANCED,
3009 },
3010 {
3011 .label = "stat cache",
3012 .type = P_BOOL,
3013 .p_class = P_GLOBAL,
3014 .ptr = &Globals.bStatCache,
3015 .special = NULL,
3016 .enum_list = NULL,
3017 .flags = FLAG_ADVANCED,
3018 },
3019 {
3020 .label = "store dos attributes",
3021 .type = P_BOOL,
3022 .p_class = P_LOCAL,
3023 .ptr = &sDefault.bStoreDosAttributes,
3024 .special = NULL,
3025 .enum_list = NULL,
3026 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3027 },
3028 {
3029 .label = "dmapi support",
3030 .type = P_BOOL,
3031 .p_class = P_LOCAL,
3032 .ptr = &sDefault.bDmapiSupport,
3033 .special = NULL,
3034 .enum_list = NULL,
3035 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3036 },
3037
3038
3039 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3040
3041 {
3042 .label = "machine password timeout",
3043 .type = P_INTEGER,
3044 .p_class = P_GLOBAL,
3045 .ptr = &Globals.machine_password_timeout,
3046 .special = NULL,
3047 .enum_list = NULL,
3048 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3049 },
3050
3051 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3052
3053 {
3054 .label = "add user script",
3055 .type = P_STRING,
3056 .p_class = P_GLOBAL,
3057 .ptr = &Globals.szAddUserScript,
3058 .special = NULL,
3059 .enum_list = NULL,
3060 .flags = FLAG_ADVANCED,
3061 },
3062 {
3063 .label = "rename user script",
3064 .type = P_STRING,
3065 .p_class = P_GLOBAL,
3066 .ptr = &Globals.szRenameUserScript,
3067 .special = NULL,
3068 .enum_list = NULL,
3069 .flags = FLAG_ADVANCED,
3070 },
3071 {
3072 .label = "delete user script",
3073 .type = P_STRING,
3074 .p_class = P_GLOBAL,
3075 .ptr = &Globals.szDelUserScript,
3076 .special = NULL,
3077 .enum_list = NULL,
3078 .flags = FLAG_ADVANCED,
3079 },
3080 {
3081 .label = "add group script",
3082 .type = P_STRING,
3083 .p_class = P_GLOBAL,
3084 .ptr = &Globals.szAddGroupScript,
3085 .special = NULL,
3086 .enum_list = NULL,
3087 .flags = FLAG_ADVANCED,
3088 },
3089 {
3090 .label = "delete group script",
3091 .type = P_STRING,
3092 .p_class = P_GLOBAL,
3093 .ptr = &Globals.szDelGroupScript,
3094 .special = NULL,
3095 .enum_list = NULL,
3096 .flags = FLAG_ADVANCED,
3097 },
3098 {
3099 .label = "add user to group script",
3100 .type = P_STRING,
3101 .p_class = P_GLOBAL,
3102 .ptr = &Globals.szAddUserToGroupScript,
3103 .special = NULL,
3104 .enum_list = NULL,
3105 .flags = FLAG_ADVANCED,
3106 },
3107 {
3108 .label = "delete user from group script",
3109 .type = P_STRING,
3110 .p_class = P_GLOBAL,
3111 .ptr = &Globals.szDelUserFromGroupScript,
3112 .special = NULL,
3113 .enum_list = NULL,
3114 .flags = FLAG_ADVANCED,
3115 },
3116 {
3117 .label = "set primary group script",
3118 .type = P_STRING,
3119 .p_class = P_GLOBAL,
3120 .ptr = &Globals.szSetPrimaryGroupScript,
3121 .special = NULL,
3122 .enum_list = NULL,
3123 .flags = FLAG_ADVANCED,
3124 },
3125 {
3126 .label = "add machine script",
3127 .type = P_STRING,
3128 .p_class = P_GLOBAL,
3129 .ptr = &Globals.szAddMachineScript,
3130 .special = NULL,
3131 .enum_list = NULL,
3132 .flags = FLAG_ADVANCED,
3133 },
3134 {
3135 .label = "shutdown script",
3136 .type = P_STRING,
3137 .p_class = P_GLOBAL,
3138 .ptr = &Globals.szShutdownScript,
3139 .special = NULL,
3140 .enum_list = NULL,
3141 .flags = FLAG_ADVANCED,
3142 },
3143 {
3144 .label = "abort shutdown script",
3145 .type = P_STRING,
3146 .p_class = P_GLOBAL,
3147 .ptr = &Globals.szAbortShutdownScript,
3148 .special = NULL,
3149 .enum_list = NULL,
3150 .flags = FLAG_ADVANCED,
3151 },
3152 {
3153 .label = "username map script",
3154 .type = P_STRING,
3155 .p_class = P_GLOBAL,
3156 .ptr = &Globals.szUsernameMapScript,
3157 .special = NULL,
3158 .enum_list = NULL,
3159 .flags = FLAG_ADVANCED,
3160 },
3161 {
3162 .label = "logon script",
3163 .type = P_STRING,
3164 .p_class = P_GLOBAL,
3165 .ptr = &Globals.szLogonScript,
3166 .special = NULL,
3167 .enum_list = NULL,
3168 .flags = FLAG_ADVANCED,
3169 },
3170 {
3171 .label = "logon path",
3172 .type = P_STRING,
3173 .p_class = P_GLOBAL,
3174 .ptr = &Globals.szLogonPath,
3175 .special = NULL,
3176 .enum_list = NULL,
3177 .flags = FLAG_ADVANCED,
3178 },
3179 {
3180 .label = "logon drive",
3181 .type = P_STRING,
3182 .p_class = P_GLOBAL,
3183 .ptr = &Globals.szLogonDrive,
3184 .special = NULL,
3185 .enum_list = NULL,
3186 .flags = FLAG_ADVANCED,
3187 },
3188 {
3189 .label = "logon home",
3190 .type = P_STRING,
3191 .p_class = P_GLOBAL,
3192 .ptr = &Globals.szLogonHome,
3193 .special = NULL,
3194 .enum_list = NULL,
3195 .flags = FLAG_ADVANCED,
3196 },
3197 {
3198 .label = "domain logons",
3199 .type = P_BOOL,
3200 .p_class = P_GLOBAL,
3201 .ptr = &Globals.bDomainLogons,
3202 .special = NULL,
3203 .enum_list = NULL,
3204 .flags = FLAG_ADVANCED,
3205 },
3206
3207 {
3208 .label = "init logon delayed hosts",
3209 .type = P_LIST,
3210 .p_class = P_GLOBAL,
3211 .ptr = &Globals.szInitLogonDelayedHosts,
3212 .flags = FLAG_ADVANCED,
3213 },
3214
3215 {
3216 .label = "init logon delay",
3217 .type = P_INTEGER,
3218 .p_class = P_GLOBAL,
3219 .ptr = &Globals.InitLogonDelay,
3220 .flags = FLAG_ADVANCED,
3221
3222 },
3223
3224 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3225
3226 {
3227 .label = "os level",
3228 .type = P_INTEGER,
3229 .p_class = P_GLOBAL,
3230 .ptr = &Globals.os_level,
3231 .special = NULL,
3232 .enum_list = NULL,
3233 .flags = FLAG_BASIC | FLAG_ADVANCED,
3234 },
3235 {
3236 .label = "lm announce",
3237 .type = P_ENUM,
3238 .p_class = P_GLOBAL,
3239 .ptr = &Globals.lm_announce,
3240 .special = NULL,
3241 .enum_list = enum_bool_auto,
3242 .flags = FLAG_ADVANCED,
3243 },
3244 {
3245 .label = "lm interval",
3246 .type = P_INTEGER,
3247 .p_class = P_GLOBAL,
3248 .ptr = &Globals.lm_interval,
3249 .special = NULL,
3250 .enum_list = NULL,
3251 .flags = FLAG_ADVANCED,
3252 },
3253 {
3254 .label = "preferred master",
3255 .type = P_ENUM,
3256 .p_class = P_GLOBAL,
3257 .ptr = &Globals.iPreferredMaster,
3258 .special = NULL,
3259 .enum_list = enum_bool_auto,
3260 .flags = FLAG_BASIC | FLAG_ADVANCED,
3261 },
3262 {
3263 .label = "prefered master",
3264 .type = P_ENUM,
3265 .p_class = P_GLOBAL,
3266 .ptr = &Globals.iPreferredMaster,
3267 .special = NULL,
3268 .enum_list = enum_bool_auto,
3269 .flags = FLAG_HIDE,
3270 },
3271 {
3272 .label = "local master",
3273 .type = P_BOOL,
3274 .p_class = P_GLOBAL,
3275 .ptr = &Globals.bLocalMaster,
3276 .special = NULL,
3277 .enum_list = NULL,
3278 .flags = FLAG_BASIC | FLAG_ADVANCED,
3279 },
3280 {
3281 .label = "domain master",
3282 .type = P_ENUM,
3283 .p_class = P_GLOBAL,
3284 .ptr = &Globals.iDomainMaster,
3285 .special = NULL,
3286 .enum_list = enum_bool_auto,
3287 .flags = FLAG_BASIC | FLAG_ADVANCED,
3288 },
3289 {
3290 .label = "browse list",
3291 .type = P_BOOL,
3292 .p_class = P_GLOBAL,
3293 .ptr = &Globals.bBrowseList,
3294 .special = NULL,
3295 .enum_list = NULL,
3296 .flags = FLAG_ADVANCED,
3297 },
3298 {
3299 .label = "browseable",
3300 .type = P_BOOL,
3301 .p_class = P_LOCAL,
3302 .ptr = &sDefault.bBrowseable,
3303 .special = NULL,
3304 .enum_list = NULL,
3305 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3306 },
3307 {
3308 .label = "browsable",
3309 .type = P_BOOL,
3310 .p_class = P_LOCAL,
3311 .ptr = &sDefault.bBrowseable,
3312 .special = NULL,
3313 .enum_list = NULL,
3314 .flags = FLAG_HIDE,
3315 },
3316 {
3317 .label = "enhanced browsing",
3318 .type = P_BOOL,
3319 .p_class = P_GLOBAL,
3320 .ptr = &Globals.enhanced_browsing,
3321 .special = NULL,
3322 .enum_list = NULL,
3323 .flags = FLAG_ADVANCED,
3324 },
3325
3326 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3327
3328 {
3329 .label = "dns proxy",
3330 .type = P_BOOL,
3331 .p_class = P_GLOBAL,
3332 .ptr = &Globals.bDNSproxy,
3333 .special = NULL,
3334 .enum_list = NULL,
3335 .flags = FLAG_ADVANCED,
3336 },
3337 {
3338 .label = "wins proxy",
3339 .type = P_BOOL,
3340 .p_class = P_GLOBAL,
3341 .ptr = &Globals.bWINSproxy,
3342 .special = NULL,
3343 .enum_list = NULL,
3344 .flags = FLAG_ADVANCED,
3345 },
3346 {
3347 .label = "wins server",
3348 .type = P_LIST,
3349 .p_class = P_GLOBAL,
3350 .ptr = &Globals.szWINSservers,
3351 .special = NULL,
3352 .enum_list = NULL,
3353 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3354 },
3355 {
3356 .label = "wins support",
3357 .type = P_BOOL,
3358 .p_class = P_GLOBAL,
3359 .ptr = &Globals.bWINSsupport,
3360 .special = NULL,
3361 .enum_list = NULL,
3362 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3363 },
3364 {
3365 .label = "wins hook",
3366 .type = P_STRING,
3367 .p_class = P_GLOBAL,
3368 .ptr = &Globals.szWINSHook,
3369 .special = NULL,
3370 .enum_list = NULL,
3371 .flags = FLAG_ADVANCED,
3372 },
3373
3374 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3375
3376 {
3377 .label = "blocking locks",
3378 .type = P_BOOL,
3379 .p_class = P_LOCAL,
3380 .ptr = &sDefault.bBlockingLocks,
3381 .special = NULL,
3382 .enum_list = NULL,
3383 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3384 },
3385 {
3386 .label = "csc policy",
3387 .type = P_ENUM,
3388 .p_class = P_LOCAL,
3389 .ptr = &sDefault.iCSCPolicy,
3390 .special = NULL,
3391 .enum_list = enum_csc_policy,
3392 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3393 },
3394 {
3395 .label = "fake oplocks",
3396 .type = P_BOOL,
3397 .p_class = P_LOCAL,
3398 .ptr = &sDefault.bFakeOplocks,
3399 .special = NULL,
3400 .enum_list = NULL,
3401 .flags = FLAG_ADVANCED | FLAG_SHARE,
3402 },
3403 {
3404 .label = "kernel oplocks",
3405 .type = P_BOOL,
3406 .p_class = P_GLOBAL,
3407 .ptr = &Globals.bKernelOplocks,
3408 .special = NULL,
3409 .enum_list = NULL,
3410 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3411 },
3412 {
3413 .label = "locking",
3414 .type = P_BOOL,
3415 .p_class = P_LOCAL,
3416 .ptr = &sDefault.bLocking,
3417 .special = NULL,
3418 .enum_list = NULL,
3419 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3420 },
3421 {
3422 .label = "lock spin time",
3423 .type = P_INTEGER,
3424 .p_class = P_GLOBAL,
3425 .ptr = &Globals.iLockSpinTime,
3426 .special = NULL,
3427 .enum_list = NULL,
3428 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3429 },
3430 {
3431 .label = "oplocks",
3432 .type = P_BOOL,
3433 .p_class = P_LOCAL,
3434 .ptr = &sDefault.bOpLocks,
3435 .special = NULL,
3436 .enum_list = NULL,
3437 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3438 },
3439 {
3440 .label = "level2 oplocks",
3441 .type = P_BOOL,
3442 .p_class = P_LOCAL,
3443 .ptr = &sDefault.bLevel2OpLocks,
3444 .special = NULL,
3445 .enum_list = NULL,
3446 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3447 },
3448 {
3449 .label = "oplock break wait time",
3450 .type = P_INTEGER,
3451 .p_class = P_GLOBAL,
3452 .ptr = &Globals.oplock_break_wait_time,
3453 .special = NULL,
3454 .enum_list = NULL,
3455 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3456 },
3457 {
3458 .label = "oplock contention limit",
3459 .type = P_INTEGER,
3460 .p_class = P_LOCAL,
3461 .ptr = &sDefault.iOplockContentionLimit,
3462 .special = NULL,
3463 .enum_list = NULL,
3464 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3465 },
3466 {
3467 .label = "posix locking",
3468 .type = P_BOOL,
3469 .p_class = P_LOCAL,
3470 .ptr = &sDefault.bPosixLocking,
3471 .special = NULL,
3472 .enum_list = NULL,
3473 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3474 },
3475 {
3476 .label = "strict locking",
3477 .type = P_ENUM,
3478 .p_class = P_LOCAL,
3479 .ptr = &sDefault.iStrictLocking,
3480 .special = NULL,
3481 .enum_list = enum_bool_auto,
3482 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3483 },
3484 {
3485 .label = "share modes",
3486 .type = P_BOOL,
3487 .p_class = P_LOCAL,
3488 .ptr = &sDefault.bShareModes,
3489 .special = NULL,
3490 .enum_list = NULL,
3491 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3492 },
3493
3494 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3495
3496 {
3497 .label = "ldap admin dn",
3498 .type = P_STRING,
3499 .p_class = P_GLOBAL,
3500 .ptr = &Globals.szLdapAdminDn,
3501 .special = NULL,
3502 .enum_list = NULL,
3503 .flags = FLAG_ADVANCED,
3504 },
3505 {
3506 .label = "ldap delete dn",
3507 .type = P_BOOL,
3508 .p_class = P_GLOBAL,
3509 .ptr = &Globals.ldap_delete_dn,
3510 .special = NULL,
3511 .enum_list = NULL,
3512 .flags = FLAG_ADVANCED,
3513 },
3514 {
3515 .label = "ldap group suffix",
3516 .type = P_STRING,
3517 .p_class = P_GLOBAL,
3518 .ptr = &Globals.szLdapGroupSuffix,
3519 .special = NULL,
3520 .enum_list = NULL,
3521 .flags = FLAG_ADVANCED,
3522 },
3523 {
3524 .label = "ldap idmap suffix",
3525 .type = P_STRING,
3526 .p_class = P_GLOBAL,
3527 .ptr = &Globals.szLdapIdmapSuffix,
3528 .special = NULL,
3529 .enum_list = NULL,
3530 .flags = FLAG_ADVANCED,
3531 },
3532 {
3533 .label = "ldap machine suffix",
3534 .type = P_STRING,
3535 .p_class = P_GLOBAL,
3536 .ptr = &Globals.szLdapMachineSuffix,
3537 .special = NULL,
3538 .enum_list = NULL,
3539 .flags = FLAG_ADVANCED,
3540 },
3541 {
3542 .label = "ldap passwd sync",
3543 .type = P_ENUM,
3544 .p_class = P_GLOBAL,
3545 .ptr = &Globals.ldap_passwd_sync,
3546 .special = NULL,
3547 .enum_list = enum_ldap_passwd_sync,
3548 .flags = FLAG_ADVANCED,
3549 },
3550 {
3551 .label = "ldap password sync",
3552 .type = P_ENUM,
3553 .p_class = P_GLOBAL,
3554 .ptr = &Globals.ldap_passwd_sync,
3555 .special = NULL,
3556 .enum_list = enum_ldap_passwd_sync,
3557 .flags = FLAG_HIDE,
3558 },
3559 {
3560 .label = "ldap replication sleep",
3561 .type = P_INTEGER,
3562 .p_class = P_GLOBAL,
3563 .ptr = &Globals.ldap_replication_sleep,
3564 .special = NULL,
3565 .enum_list = NULL,
3566 .flags = FLAG_ADVANCED,
3567 },
3568 {
3569 .label = "ldap suffix",
3570 .type = P_STRING,
3571 .p_class = P_GLOBAL,
3572 .ptr = &Globals.szLdapSuffix,
3573 .special = NULL,
3574 .enum_list = NULL,
3575 .flags = FLAG_ADVANCED,
3576 },
3577 {
3578 .label = "ldap ssl",
3579 .type = P_ENUM,
3580 .p_class = P_GLOBAL,
3581 .ptr = &Globals.ldap_ssl,
3582 .special = NULL,
3583 .enum_list = enum_ldap_ssl,
3584 .flags = FLAG_ADVANCED,
3585 },
3586 {
3587 .label = "ldap ssl ads",
3588 .type = P_BOOL,
3589 .p_class = P_GLOBAL,
3590 .ptr = &Globals.ldap_ssl_ads,
3591 .special = NULL,
3592 .enum_list = NULL,
3593 .flags = FLAG_ADVANCED,
3594 },
3595 {
3596 .label = "ldap timeout",
3597 .type = P_INTEGER,
3598 .p_class = P_GLOBAL,
3599 .ptr = &Globals.ldap_timeout,
3600 .special = NULL,
3601 .enum_list = NULL,
3602 .flags = FLAG_ADVANCED,
3603 },
3604 {
3605 .label = "ldap connection timeout",
3606 .type = P_INTEGER,
3607 .p_class = P_GLOBAL,
3608 .ptr = &Globals.ldap_connection_timeout,
3609 .special = NULL,
3610 .enum_list = NULL,
3611 .flags = FLAG_ADVANCED,
3612 },
3613 {
3614 .label = "ldap page size",
3615 .type = P_INTEGER,
3616 .p_class = P_GLOBAL,
3617 .ptr = &Globals.ldap_page_size,
3618 .special = NULL,
3619 .enum_list = NULL,
3620 .flags = FLAG_ADVANCED,
3621 },
3622 {
3623 .label = "ldap user suffix",
3624 .type = P_STRING,
3625 .p_class = P_GLOBAL,
3626 .ptr = &Globals.szLdapUserSuffix,
3627 .special = NULL,
3628 .enum_list = NULL,
3629 .flags = FLAG_ADVANCED,
3630 },
3631 {
3632 .label = "ldap debug level",
3633 .type = P_INTEGER,
3634 .p_class = P_GLOBAL,
3635 .ptr = &Globals.ldap_debug_level,
3636 .special = handle_ldap_debug_level,
3637 .enum_list = NULL,
3638 .flags = FLAG_ADVANCED,
3639 },
3640 {
3641 .label = "ldap debug threshold",
3642 .type = P_INTEGER,
3643 .p_class = P_GLOBAL,
3644 .ptr = &Globals.ldap_debug_threshold,
3645 .special = NULL,
3646 .enum_list = NULL,
3647 .flags = FLAG_ADVANCED,
3648 },
3649
3650 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3651
3652 {
3653 .label = "eventlog list",
3654 .type = P_LIST,
3655 .p_class = P_GLOBAL,
3656 .ptr = &Globals.szEventLogs,
3657 .special = NULL,
3658 .enum_list = NULL,
3659 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3660 },
3661
3662 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3663
3664 {
3665 .label = "add share command",
3666 .type = P_STRING,
3667 .p_class = P_GLOBAL,
3668 .ptr = &Globals.szAddShareCommand,
3669 .special = NULL,
3670 .enum_list = NULL,
3671 .flags = FLAG_ADVANCED,
3672 },
3673 {
3674 .label = "change share command",
3675 .type = P_STRING,
3676 .p_class = P_GLOBAL,
3677 .ptr = &Globals.szChangeShareCommand,
3678 .special = NULL,
3679 .enum_list = NULL,
3680 .flags = FLAG_ADVANCED,
3681 },
3682 {
3683 .label = "delete share command",
3684 .type = P_STRING,
3685 .p_class = P_GLOBAL,
3686 .ptr = &Globals.szDeleteShareCommand,
3687 .special = NULL,
3688 .enum_list = NULL,
3689 .flags = FLAG_ADVANCED,
3690 },
3691 {
3692 .label = "config file",
3693 .type = P_STRING,
3694 .p_class = P_GLOBAL,
3695 .ptr = &Globals.szConfigFile,
3696 .special = NULL,
3697 .enum_list = NULL,
3698 .flags = FLAG_HIDE,
3699 },
3700 {
3701 .label = "preload",
3702 .type = P_STRING,
3703 .p_class = P_GLOBAL,
3704 .ptr = &Globals.szAutoServices,
3705 .special = NULL,
3706 .enum_list = NULL,
3707 .flags = FLAG_ADVANCED,
3708 },
3709 {
3710 .label = "auto services",
3711 .type = P_STRING,
3712 .p_class = P_GLOBAL,
3713 .ptr = &Globals.szAutoServices,
3714 .special = NULL,
3715 .enum_list = NULL,
3716 .flags = FLAG_ADVANCED,
3717 },
3718 {
3719 .label = "lock directory",
3720 .type = P_STRING,
3721 .p_class = P_GLOBAL,
3722 .ptr = &Globals.szLockDir,
3723 .special = NULL,
3724 .enum_list = NULL,
3725 .flags = FLAG_ADVANCED,
3726 },
3727 {
3728 .label = "lock dir",
3729 .type = P_STRING,
3730 .p_class = P_GLOBAL,
3731 .ptr = &Globals.szLockDir,
3732 .special = NULL,
3733 .enum_list = NULL,
3734 .flags = FLAG_HIDE,
3735 },
3736 {
3737 .label = "pid directory",
3738 .type = P_STRING,
3739 .p_class = P_GLOBAL,
3740 .ptr = &Globals.szPidDir,
3741 .special = NULL,
3742 .enum_list = NULL,
3743 .flags = FLAG_ADVANCED,
3744 },
3745#ifdef WITH_UTMP
3746 {
3747 .label = "utmp directory",
3748 .type = P_STRING,
3749 .p_class = P_GLOBAL,
3750 .ptr = &Globals.szUtmpDir,
3751 .special = NULL,
3752 .enum_list = NULL,
3753 .flags = FLAG_ADVANCED,
3754 },
3755 {
3756 .label = "wtmp directory",
3757 .type = P_STRING,
3758 .p_class = P_GLOBAL,
3759 .ptr = &Globals.szWtmpDir,
3760 .special = NULL,
3761 .enum_list = NULL,
3762 .flags = FLAG_ADVANCED,
3763 },
3764 {
3765 .label = "utmp",
3766 .type = P_BOOL,
3767 .p_class = P_GLOBAL,
3768 .ptr = &Globals.bUtmp,
3769 .special = NULL,
3770 .enum_list = NULL,
3771 .flags = FLAG_ADVANCED,
3772 },
3773#endif
3774 {
3775 .label = "default service",
3776 .type = P_STRING,
3777 .p_class = P_GLOBAL,
3778 .ptr = &Globals.szDefaultService,
3779 .special = NULL,
3780 .enum_list = NULL,
3781 .flags = FLAG_ADVANCED,
3782 },
3783 {
3784 .label = "default",
3785 .type = P_STRING,
3786 .p_class = P_GLOBAL,
3787 .ptr = &Globals.szDefaultService,
3788 .special = NULL,
3789 .enum_list = NULL,
3790 .flags = FLAG_ADVANCED,
3791 },
3792 {
3793 .label = "message command",
3794 .type = P_STRING,
3795 .p_class = P_GLOBAL,
3796 .ptr = &Globals.szMsgCommand,
3797 .special = NULL,
3798 .enum_list = NULL,
3799 .flags = FLAG_ADVANCED,
3800 },
3801 {
3802 .label = "dfree cache time",
3803 .type = P_INTEGER,
3804 .p_class = P_LOCAL,
3805 .ptr = &sDefault.iDfreeCacheTime,
3806 .special = NULL,
3807 .enum_list = NULL,
3808 .flags = FLAG_ADVANCED,
3809 },
3810 {
3811 .label = "dfree command",
3812 .type = P_STRING,
3813 .p_class = P_LOCAL,
3814 .ptr = &sDefault.szDfree,
3815 .special = NULL,
3816 .enum_list = NULL,
3817 .flags = FLAG_ADVANCED,
3818 },
3819 {
3820 .label = "get quota command",
3821 .type = P_STRING,
3822 .p_class = P_GLOBAL,
3823 .ptr = &Globals.szGetQuota,
3824 .special = NULL,
3825 .enum_list = NULL,
3826 .flags = FLAG_ADVANCED,
3827 },
3828 {
3829 .label = "set quota command",
3830 .type = P_STRING,
3831 .p_class = P_GLOBAL,
3832 .ptr = &Globals.szSetQuota,
3833 .special = NULL,
3834 .enum_list = NULL,
3835 .flags = FLAG_ADVANCED,
3836 },
3837 {
3838 .label = "remote announce",
3839 .type = P_STRING,
3840 .p_class = P_GLOBAL,
3841 .ptr = &Globals.szRemoteAnnounce,
3842 .special = NULL,
3843 .enum_list = NULL,
3844 .flags = FLAG_ADVANCED,
3845 },
3846 {
3847 .label = "remote browse sync",
3848 .type = P_STRING,
3849 .p_class = P_GLOBAL,
3850 .ptr = &Globals.szRemoteBrowseSync,
3851 .special = NULL,
3852 .enum_list = NULL,
3853 .flags = FLAG_ADVANCED,
3854 },
3855 {
3856 .label = "socket address",
3857 .type = P_STRING,
3858 .p_class = P_GLOBAL,
3859 .ptr = &Globals.szSocketAddress,
3860 .special = NULL,
3861 .enum_list = NULL,
3862 .flags = FLAG_ADVANCED,
3863 },
3864 {
3865 .label = "homedir map",
3866 .type = P_STRING,
3867 .p_class = P_GLOBAL,
3868 .ptr = &Globals.szNISHomeMapName,
3869 .special = NULL,
3870 .enum_list = NULL,
3871 .flags = FLAG_ADVANCED,
3872 },
3873 {
3874 .label = "afs username map",
3875 .type = P_STRING,
3876 .p_class = P_GLOBAL,
3877 .ptr = &Globals.szAfsUsernameMap,
3878 .special = NULL,
3879 .enum_list = NULL,
3880 .flags = FLAG_ADVANCED,
3881 },
3882 {
3883 .label = "afs token lifetime",
3884 .type = P_INTEGER,
3885 .p_class = P_GLOBAL,
3886 .ptr = &Globals.iAfsTokenLifetime,
3887 .special = NULL,
3888 .enum_list = NULL,
3889 .flags = FLAG_ADVANCED,
3890 },
3891 {
3892 .label = "log nt token command",
3893 .type = P_STRING,
3894 .p_class = P_GLOBAL,
3895 .ptr = &Globals.szLogNtTokenCommand,
3896 .special = NULL,
3897 .enum_list = NULL,
3898 .flags = FLAG_ADVANCED,
3899 },
3900 {
3901 .label = "time offset",
3902 .type = P_INTEGER,
3903 .p_class = P_GLOBAL,
3904 .ptr = &extra_time_offset,
3905 .special = NULL,
3906 .enum_list = NULL,
3907 .flags = FLAG_ADVANCED,
3908 },
3909 {
3910 .label = "NIS homedir",
3911 .type = P_BOOL,
3912 .p_class = P_GLOBAL,
3913 .ptr = &Globals.bNISHomeMap,
3914 .special = NULL,
3915 .enum_list = NULL,
3916 .flags = FLAG_ADVANCED,
3917 },
3918 {
3919 .label = "-valid",
3920 .type = P_BOOL,
3921 .p_class = P_LOCAL,
3922 .ptr = &sDefault.valid,
3923 .special = NULL,
3924 .enum_list = NULL,
3925 .flags = FLAG_HIDE,
3926 },
3927 {
3928 .label = "copy",
3929 .type = P_STRING,
3930 .p_class = P_LOCAL,
3931 .ptr = &sDefault.szCopy,
3932 .special = handle_copy,
3933 .enum_list = NULL,
3934 .flags = FLAG_HIDE,
3935 },
3936 {
3937 .label = "include",
3938 .type = P_STRING,
3939 .p_class = P_LOCAL,
3940 .ptr = &sDefault.szInclude,
3941 .special = handle_include,
3942 .enum_list = NULL,
3943 .flags = FLAG_HIDE,
3944 },
3945 {
3946 .label = "preexec",
3947 .type = P_STRING,
3948 .p_class = P_LOCAL,
3949 .ptr = &sDefault.szPreExec,
3950 .special = NULL,
3951 .enum_list = NULL,
3952 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3953 },
3954 {
3955 .label = "exec",
3956 .type = P_STRING,
3957 .p_class = P_LOCAL,
3958 .ptr = &sDefault.szPreExec,
3959 .special = NULL,
3960 .enum_list = NULL,
3961 .flags = FLAG_ADVANCED,
3962 },
3963 {
3964 .label = "preexec close",
3965 .type = P_BOOL,
3966 .p_class = P_LOCAL,
3967 .ptr = &sDefault.bPreexecClose,
3968 .special = NULL,
3969 .enum_list = NULL,
3970 .flags = FLAG_ADVANCED | FLAG_SHARE,
3971 },
3972 {
3973 .label = "postexec",
3974 .type = P_STRING,
3975 .p_class = P_LOCAL,
3976 .ptr = &sDefault.szPostExec,
3977 .special = NULL,
3978 .enum_list = NULL,
3979 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3980 },
3981 {
3982 .label = "root preexec",
3983 .type = P_STRING,
3984 .p_class = P_LOCAL,
3985 .ptr = &sDefault.szRootPreExec,
3986 .special = NULL,
3987 .enum_list = NULL,
3988 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3989 },
3990 {
3991 .label = "root preexec close",
3992 .type = P_BOOL,
3993 .p_class = P_LOCAL,
3994 .ptr = &sDefault.bRootpreexecClose,
3995 .special = NULL,
3996 .enum_list = NULL,
3997 .flags = FLAG_ADVANCED | FLAG_SHARE,
3998 },
3999 {
4000 .label = "root postexec",
4001 .type = P_STRING,
4002 .p_class = P_LOCAL,
4003 .ptr = &sDefault.szRootPostExec,
4004 .special = NULL,
4005 .enum_list = NULL,
4006 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4007 },
4008 {
4009 .label = "available",
4010 .type = P_BOOL,
4011 .p_class = P_LOCAL,
4012 .ptr = &sDefault.bAvailable,
4013 .special = NULL,
4014 .enum_list = NULL,
4015 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4016 },
4017 {
4018 .label = "registry shares",
4019 .type = P_BOOL,
4020 .p_class = P_GLOBAL,
4021 .ptr = &Globals.bRegistryShares,
4022 .special = NULL,
4023 .enum_list = NULL,
4024 .flags = FLAG_ADVANCED,
4025 },
4026 {
4027 .label = "usershare allow guests",
4028 .type = P_BOOL,
4029 .p_class = P_GLOBAL,
4030 .ptr = &Globals.bUsershareAllowGuests,
4031 .special = NULL,
4032 .enum_list = NULL,
4033 .flags = FLAG_ADVANCED,
4034 },
4035 {
4036 .label = "usershare max shares",
4037 .type = P_INTEGER,
4038 .p_class = P_GLOBAL,
4039 .ptr = &Globals.iUsershareMaxShares,
4040 .special = NULL,
4041 .enum_list = NULL,
4042 .flags = FLAG_ADVANCED,
4043 },
4044 {
4045 .label = "usershare owner only",
4046 .type = P_BOOL,
4047 .p_class = P_GLOBAL,
4048 .ptr = &Globals.bUsershareOwnerOnly,
4049 .special = NULL,
4050 .enum_list = NULL,
4051 .flags = FLAG_ADVANCED,
4052 },
4053 {
4054 .label = "usershare path",
4055 .type = P_STRING,
4056 .p_class = P_GLOBAL,
4057 .ptr = &Globals.szUsersharePath,
4058 .special = NULL,
4059 .enum_list = NULL,
4060 .flags = FLAG_ADVANCED,
4061 },
4062 {
4063 .label = "usershare prefix allow list",
4064 .type = P_LIST,
4065 .p_class = P_GLOBAL,
4066 .ptr = &Globals.szUsersharePrefixAllowList,
4067 .special = NULL,
4068 .enum_list = NULL,
4069 .flags = FLAG_ADVANCED,
4070 },
4071 {
4072 .label = "usershare prefix deny list",
4073 .type = P_LIST,
4074 .p_class = P_GLOBAL,
4075 .ptr = &Globals.szUsersharePrefixDenyList,
4076 .special = NULL,
4077 .enum_list = NULL,
4078 .flags = FLAG_ADVANCED,
4079 },
4080 {
4081 .label = "usershare template share",
4082 .type = P_STRING,
4083 .p_class = P_GLOBAL,
4084 .ptr = &Globals.szUsershareTemplateShare,
4085 .special = NULL,
4086 .enum_list = NULL,
4087 .flags = FLAG_ADVANCED,
4088 },
4089 {
4090 .label = "volume",
4091 .type = P_STRING,
4092 .p_class = P_LOCAL,
4093 .ptr = &sDefault.volume,
4094 .special = NULL,
4095 .enum_list = NULL,
4096 .flags = FLAG_ADVANCED | FLAG_SHARE,
4097 },
4098 {
4099 .label = "fstype",
4100 .type = P_STRING,
4101 .p_class = P_LOCAL,
4102 .ptr = &sDefault.fstype,
4103 .special = NULL,
4104 .enum_list = NULL,
4105 .flags = FLAG_ADVANCED | FLAG_SHARE,
4106 },
4107 {
4108 .label = "set directory",
4109 .type = P_BOOLREV,
4110 .p_class = P_LOCAL,
4111 .ptr = &sDefault.bNo_set_dir,
4112 .special = NULL,
4113 .enum_list = NULL,
4114 .flags = FLAG_ADVANCED | FLAG_SHARE,
4115 },
4116 {
4117 .label = "wide links",
4118 .type = P_BOOL,
4119 .p_class = P_LOCAL,
4120 .ptr = &sDefault.bWidelinks,
4121 .special = NULL,
4122 .enum_list = NULL,
4123 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4124 },
4125 {
4126 .label = "follow symlinks",
4127 .type = P_BOOL,
4128 .p_class = P_LOCAL,
4129 .ptr = &sDefault.bSymlinks,
4130 .special = NULL,
4131 .enum_list = NULL,
4132 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4133 },
4134 {
4135 .label = "dont descend",
4136 .type = P_STRING,
4137 .p_class = P_LOCAL,
4138 .ptr = &sDefault.szDontdescend,
4139 .special = NULL,
4140 .enum_list = NULL,
4141 .flags = FLAG_ADVANCED | FLAG_SHARE,
4142 },
4143 {
4144 .label = "magic script",
4145 .type = P_STRING,
4146 .p_class = P_LOCAL,
4147 .ptr = &sDefault.szMagicScript,
4148 .special = NULL,
4149 .enum_list = NULL,
4150 .flags = FLAG_ADVANCED | FLAG_SHARE,
4151 },
4152 {
4153 .label = "magic output",
4154 .type = P_STRING,
4155 .p_class = P_LOCAL,
4156 .ptr = &sDefault.szMagicOutput,
4157 .special = NULL,
4158 .enum_list = NULL,
4159 .flags = FLAG_ADVANCED | FLAG_SHARE,
4160 },
4161 {
4162 .label = "delete readonly",
4163 .type = P_BOOL,
4164 .p_class = P_LOCAL,
4165 .ptr = &sDefault.bDeleteReadonly,
4166 .special = NULL,
4167 .enum_list = NULL,
4168 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4169 },
4170 {
4171 .label = "dos filemode",
4172 .type = P_BOOL,
4173 .p_class = P_LOCAL,
4174 .ptr = &sDefault.bDosFilemode,
4175 .special = NULL,
4176 .enum_list = NULL,
4177 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4178 },
4179 {
4180 .label = "dos filetimes",
4181 .type = P_BOOL,
4182 .p_class = P_LOCAL,
4183 .ptr = &sDefault.bDosFiletimes,
4184 .special = NULL,
4185 .enum_list = NULL,
4186 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4187 },
4188 {
4189 .label = "dos filetime resolution",
4190 .type = P_BOOL,
4191 .p_class = P_LOCAL,
4192 .ptr = &sDefault.bDosFiletimeResolution,
4193 .special = NULL,
4194 .enum_list = NULL,
4195 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4196 },
4197 {
4198 .label = "fake directory create times",
4199 .type = P_BOOL,
4200 .p_class = P_LOCAL,
4201 .ptr = &sDefault.bFakeDirCreateTimes,
4202 .special = NULL,
4203 .enum_list = NULL,
4204 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4205 },
4206 {
4207 .label = "panic action",
4208 .type = P_STRING,
4209 .p_class = P_GLOBAL,
4210 .ptr = &Globals.szPanicAction,
4211 .special = NULL,
4212 .enum_list = NULL,
4213 .flags = FLAG_ADVANCED,
4214 },
4215
4216 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4217
4218 {
4219 .label = "vfs objects",
4220 .type = P_LIST,
4221 .p_class = P_LOCAL,
4222 .ptr = &sDefault.szVfsObjects,
4223 .special = NULL,
4224 .enum_list = NULL,
4225 .flags = FLAG_ADVANCED | FLAG_SHARE,
4226 },
4227 {
4228 .label = "vfs object",
4229 .type = P_LIST,
4230 .p_class = P_LOCAL,
4231 .ptr = &sDefault.szVfsObjects,
4232 .special = NULL,
4233 .enum_list = NULL,
4234 .flags = FLAG_HIDE,
4235 },
4236
4237
4238 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4239
4240 {
4241 .label = "msdfs root",
4242 .type = P_BOOL,
4243 .p_class = P_LOCAL,
4244 .ptr = &sDefault.bMSDfsRoot,
4245 .special = NULL,
4246 .enum_list = NULL,
4247 .flags = FLAG_ADVANCED | FLAG_SHARE,
4248 },
4249 {
4250 .label = "msdfs proxy",
4251 .type = P_STRING,
4252 .p_class = P_LOCAL,
4253 .ptr = &sDefault.szMSDfsProxy,
4254 .special = NULL,
4255 .enum_list = NULL,
4256 .flags = FLAG_ADVANCED | FLAG_SHARE,
4257 },
4258 {
4259 .label = "host msdfs",
4260 .type = P_BOOL,
4261 .p_class = P_GLOBAL,
4262 .ptr = &Globals.bHostMSDfs,
4263 .special = NULL,
4264 .enum_list = NULL,
4265 .flags = FLAG_ADVANCED,
4266 },
4267
4268 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4269
4270 {
4271 .label = "passdb expand explicit",
4272 .type = P_BOOL,
4273 .p_class = P_GLOBAL,
4274 .ptr = &Globals.bPassdbExpandExplicit,
4275 .special = NULL,
4276 .enum_list = NULL,
4277 .flags = FLAG_ADVANCED,
4278 },
4279 {
4280 .label = "idmap backend",
4281 .type = P_STRING,
4282 .p_class = P_GLOBAL,
4283 .ptr = &Globals.szIdmapBackend,
4284 .special = NULL,
4285 .enum_list = NULL,
4286 .flags = FLAG_ADVANCED,
4287 },
4288 {
4289 .label = "idmap alloc backend",
4290 .type = P_STRING,
4291 .p_class = P_GLOBAL,
4292 .ptr = &Globals.szIdmapAllocBackend,
4293 .special = NULL,
4294 .enum_list = NULL,
4295 .flags = FLAG_ADVANCED,
4296 },
4297 {
4298 .label = "idmap cache time",
4299 .type = P_INTEGER,
4300 .p_class = P_GLOBAL,
4301 .ptr = &Globals.iIdmapCacheTime,
4302 .special = NULL,
4303 .enum_list = NULL,
4304 .flags = FLAG_ADVANCED,
4305 },
4306 {
4307 .label = "idmap negative cache time",
4308 .type = P_INTEGER,
4309 .p_class = P_GLOBAL,
4310 .ptr = &Globals.iIdmapNegativeCacheTime,
4311 .special = NULL,
4312 .enum_list = NULL,
4313 .flags = FLAG_ADVANCED,
4314 },
4315 {
4316 .label = "idmap uid",
4317 .type = P_STRING,
4318 .p_class = P_GLOBAL,
4319 .ptr = &Globals.szIdmapUID,
4320 .special = handle_idmap_uid,
4321 .enum_list = NULL,
4322 .flags = FLAG_ADVANCED,
4323 },
4324 {
4325 .label = "winbind uid",
4326 .type = P_STRING,
4327 .p_class = P_GLOBAL,
4328 .ptr = &Globals.szIdmapUID,
4329 .special = handle_idmap_uid,
4330 .enum_list = NULL,
4331 .flags = FLAG_HIDE,
4332 },
4333 {
4334 .label = "idmap gid",
4335 .type = P_STRING,
4336 .p_class = P_GLOBAL,
4337 .ptr = &Globals.szIdmapGID,
4338 .special = handle_idmap_gid,
4339 .enum_list = NULL,
4340 .flags = FLAG_ADVANCED,
4341 },
4342 {
4343 .label = "winbind gid",
4344 .type = P_STRING,
4345 .p_class = P_GLOBAL,
4346 .ptr = &Globals.szIdmapGID,
4347 .special = handle_idmap_gid,
4348 .enum_list = NULL,
4349 .flags = FLAG_HIDE,
4350 },
4351 {
4352 .label = "template homedir",
4353 .type = P_STRING,
4354 .p_class = P_GLOBAL,
4355 .ptr = &Globals.szTemplateHomedir,
4356 .special = NULL,
4357 .enum_list = NULL,
4358 .flags = FLAG_ADVANCED,
4359 },
4360 {
4361 .label = "template shell",
4362 .type = P_STRING,
4363 .p_class = P_GLOBAL,
4364 .ptr = &Globals.szTemplateShell,
4365 .special = NULL,
4366 .enum_list = NULL,
4367 .flags = FLAG_ADVANCED,
4368 },
4369 {
4370 .label = "winbind separator",
4371 .type = P_STRING,
4372 .p_class = P_GLOBAL,
4373 .ptr = &Globals.szWinbindSeparator,
4374 .special = NULL,
4375 .enum_list = NULL,
4376 .flags = FLAG_ADVANCED,
4377 },
4378 {
4379 .label = "winbind cache time",
4380 .type = P_INTEGER,
4381 .p_class = P_GLOBAL,
4382 .ptr = &Globals.winbind_cache_time,
4383 .special = NULL,
4384 .enum_list = NULL,
4385 .flags = FLAG_ADVANCED,
4386 },
4387 {
4388 .label = "winbind reconnect delay",
4389 .type = P_INTEGER,
4390 .p_class = P_GLOBAL,
4391 .ptr = &Globals.winbind_reconnect_delay,
4392 .special = NULL,
4393 .enum_list = NULL,
4394 .flags = FLAG_ADVANCED,
4395 },
4396 {
4397 .label = "winbind enum users",
4398 .type = P_BOOL,
4399 .p_class = P_GLOBAL,
4400 .ptr = &Globals.bWinbindEnumUsers,
4401 .special = NULL,
4402 .enum_list = NULL,
4403 .flags = FLAG_ADVANCED,
4404 },
4405 {
4406 .label = "winbind enum groups",
4407 .type = P_BOOL,
4408 .p_class = P_GLOBAL,
4409 .ptr = &Globals.bWinbindEnumGroups,
4410 .special = NULL,
4411 .enum_list = NULL,
4412 .flags = FLAG_ADVANCED,
4413 },
4414 {
4415 .label = "winbind use default domain",
4416 .type = P_BOOL,
4417 .p_class = P_GLOBAL,
4418 .ptr = &Globals.bWinbindUseDefaultDomain,
4419 .special = NULL,
4420 .enum_list = NULL,
4421 .flags = FLAG_ADVANCED,
4422 },
4423 {
4424 .label = "winbind trusted domains only",
4425 .type = P_BOOL,
4426 .p_class = P_GLOBAL,
4427 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4428 .special = NULL,
4429 .enum_list = NULL,
4430 .flags = FLAG_ADVANCED,
4431 },
4432 {
4433 .label = "winbind nested groups",
4434 .type = P_BOOL,
4435 .p_class = P_GLOBAL,
4436 .ptr = &Globals.bWinbindNestedGroups,
4437 .special = NULL,
4438 .enum_list = NULL,
4439 .flags = FLAG_ADVANCED,
4440 },
4441 {
4442 .label = "winbind expand groups",
4443 .type = P_INTEGER,
4444 .p_class = P_GLOBAL,
4445 .ptr = &Globals.winbind_expand_groups,
4446 .special = NULL,
4447 .enum_list = NULL,
4448 .flags = FLAG_ADVANCED,
4449 },
4450 {
4451 .label = "winbind nss info",
4452 .type = P_LIST,
4453 .p_class = P_GLOBAL,
4454 .ptr = &Globals.szWinbindNssInfo,
4455 .special = NULL,
4456 .enum_list = NULL,
4457 .flags = FLAG_ADVANCED,
4458 },
4459 {
4460 .label = "winbind refresh tickets",
4461 .type = P_BOOL,
4462 .p_class = P_GLOBAL,
4463 .ptr = &Globals.bWinbindRefreshTickets,
4464 .special = NULL,
4465 .enum_list = NULL,
4466 .flags = FLAG_ADVANCED,
4467 },
4468 {
4469 .label = "winbind offline logon",
4470 .type = P_BOOL,
4471 .p_class = P_GLOBAL,
4472 .ptr = &Globals.bWinbindOfflineLogon,
4473 .special = NULL,
4474 .enum_list = NULL,
4475 .flags = FLAG_ADVANCED,
4476 },
4477 {
4478 .label = "winbind normalize names",
4479 .type = P_BOOL,
4480 .p_class = P_GLOBAL,
4481 .ptr = &Globals.bWinbindNormalizeNames,
4482 .special = NULL,
4483 .enum_list = NULL,
4484 .flags = FLAG_ADVANCED,
4485 },
4486 {
4487 .label = "winbind rpc only",
4488 .type = P_BOOL,
4489 .p_class = P_GLOBAL,
4490 .ptr = &Globals.bWinbindRpcOnly,
4491 .special = NULL,
4492 .enum_list = NULL,
4493 .flags = FLAG_ADVANCED,
4494 },
4495
4496 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4497};
4498
4499/***************************************************************************
4500 Initialise the sDefault parameter structure for the printer values.
4501***************************************************************************/
4502
4503static void init_printer_values(struct service *pService)
4504{
4505 /* choose defaults depending on the type of printing */
4506 switch (pService->iPrinting) {
4507 case PRINT_BSD:
4508 case PRINT_AIX:
4509 case PRINT_LPRNT:
4510#ifndef __OS2__
4511 case PRINT_LPROS2:
4512#endif
4513 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4514 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4515 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4516 break;
4517#ifdef __OS2__
4518 case PRINT_LPROS2:
4519 string_set(&pService->szLpqcommand, "lpq.exe -s %i -p %p");
4520 string_set(&pService->szLprmcommand, "lprm.exe -s %i -p %p %j");
4521 string_set(&pService->szPrintcommand, "lpr.exe -b -s %i -p %p %s & cmd.exe /c del %s");
4522 break;
4523#endif
4524
4525 case PRINT_LPRNG:
4526 case PRINT_PLP:
4527 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4528 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4529 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4530 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4531 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4532 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4533 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4534 break;
4535
4536 case PRINT_CUPS:
4537 case PRINT_IPRINT:
4538#ifdef HAVE_CUPS
4539 /* set the lpq command to contain the destination printer
4540 name only. This is used by cups_queue_get() */
4541 string_set(&pService->szLpqcommand, "%p");
4542 string_set(&pService->szLprmcommand, "");
4543 string_set(&pService->szPrintcommand, "");
4544 string_set(&pService->szLppausecommand, "");
4545 string_set(&pService->szLpresumecommand, "");
4546 string_set(&pService->szQueuepausecommand, "");
4547 string_set(&pService->szQueueresumecommand, "");
4548#else
4549 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4550 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4551 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4552 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4553 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4554 string_set(&pService->szQueuepausecommand, "disable '%p'");
4555 string_set(&pService->szQueueresumecommand, "enable '%p'");
4556#endif /* HAVE_CUPS */
4557 break;
4558
4559 case PRINT_SYSV:
4560 case PRINT_HPUX:
4561 string_set(&pService->szLpqcommand, "lpstat -o%p");
4562 string_set(&pService->szLprmcommand, "cancel %p-%j");
4563 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4564 string_set(&pService->szQueuepausecommand, "disable %p");
4565 string_set(&pService->szQueueresumecommand, "enable %p");
4566#ifndef HPUX
4567 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4568 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4569#endif /* HPUX */
4570 break;
4571
4572 case PRINT_QNX:
4573 string_set(&pService->szLpqcommand, "lpq -P%p");
4574 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4575 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4576 break;
4577
4578#ifdef DEVELOPER
4579 case PRINT_TEST:
4580 case PRINT_VLP:
4581 string_set(&pService->szPrintcommand, "vlp print %p %s");
4582 string_set(&pService->szLpqcommand, "vlp lpq %p");
4583 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4584 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4585 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4586 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4587 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4588 break;
4589#endif /* DEVELOPER */
4590
4591 }
4592}
4593
4594/***************************************************************************
4595 Initialise the global parameter structure.
4596***************************************************************************/
4597
4598static void init_globals(bool first_time_only)
4599{
4600 static bool done_init = False;
4601 char *s = NULL;
4602 int i;
4603
4604 /* If requested to initialize only once and we've already done it... */
4605 if (first_time_only && done_init) {
4606 /* ... then we have nothing more to do */
4607 return;
4608 }
4609
4610 if (!done_init) {
4611 /* The logfile can be set before this is invoked. Free it if so. */
4612 if (Globals.szLogFile != NULL) {
4613 string_free(&Globals.szLogFile);
4614 Globals.szLogFile = NULL;
4615 }
4616 done_init = True;
4617 } else {
4618 for (i = 0; parm_table[i].label; i++) {
4619 if ((parm_table[i].type == P_STRING ||
4620 parm_table[i].type == P_USTRING) &&
4621 parm_table[i].ptr)
4622 {
4623 string_free((char **)parm_table[i].ptr);
4624 }
4625 }
4626 }
4627
4628 memset((void *)&Globals, '\0', sizeof(Globals));
4629
4630 for (i = 0; parm_table[i].label; i++) {
4631 if ((parm_table[i].type == P_STRING ||
4632 parm_table[i].type == P_USTRING) &&
4633 parm_table[i].ptr)
4634 {
4635 string_set((char **)parm_table[i].ptr, "");
4636 }
4637 }
4638
4639 string_set(&sDefault.fstype, FSTYPE_STRING);
4640 string_set(&sDefault.szPrintjobUsername, "%U");
4641
4642 init_printer_values(&sDefault);
4643
4644
4645 DEBUG(3, ("Initialising global parameters\n"));
4646
4647 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4648 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4649
4650 /* use the new 'hash2' method by default, with a prefix of 1 */
4651 string_set(&Globals.szManglingMethod, "hash2");
4652 Globals.mangle_prefix = 1;
4653
4654 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4655
4656#if defined (__OS2__)
4657 /* search the system codepage and set OS2CodePageStr */
4658 unsigned long _System DosQueryCp (unsigned long ulLength, unsigned long *pCodePageList, unsigned long *pDataLength);
4659 char *OS2CodePageStr=NULL;
4660 unsigned long OS2CodePage[3];
4661 unsigned long OS2CodePageLen;
4662 if ( DosQueryCp( sizeof(OS2CodePage), OS2CodePage, &OS2CodePageLen ) )
4663 asprintf(&OS2CodePageStr, "SYSTEM");
4664 else
4665 asprintf(&OS2CodePageStr, "IBM-%u", OS2CodePage[0]);
4666#endif
4667
4668#ifndef __OS2__
4669 /* using UTF8 by default allows us to support all chars */
4670 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4671#else
4672 /* On OS/2, using UTF8 causes problems with display of foreign
4673 characters - default to system codepage */
4674 string_set(&Globals.unix_charset, OS2CodePageStr);
4675#endif
4676
4677#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4678 /* If the system supports nl_langinfo(), try to grab the value
4679 from the user's locale */
4680#ifndef __OS2__
4681 /* this does somehow not work on OS/2 */
4682 string_set(&Globals.display_charset, "LOCALE");
4683#else
4684 /* On OS/2, using UTF8 causes problems with display of foreign
4685 characters - default to system codepage */
4686 string_set(&Globals.display_charset, OS2CodePageStr);
4687#endif
4688
4689#else
4690 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4691#endif
4692
4693#ifndef __OS2__
4694 /* Use codepage 850 as a default for the dos character set */
4695 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4696#else
4697 /* On OS/2, using UTF8 causes problems with display of foreign
4698 characters - default to system codepage */
4699 string_set(&Globals.dos_charset, OS2CodePageStr);
4700#endif
4701
4702 /*
4703 * Allow the default PASSWD_CHAT to be overridden in local.h.
4704 */
4705 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4706
4707 set_global_myname(myhostname());
4708 string_set(&Globals.szNetbiosName,global_myname());
4709
4710 set_global_myworkgroup(WORKGROUP);
4711 string_set(&Globals.szWorkgroup, lp_workgroup());
4712
4713 string_set(&Globals.szPasswdProgram, "");
4714 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4715 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4716 string_set(&Globals.szSocketAddress, "0.0.0.0");
4717
4718 if (asprintf(&s, "Samba %s", SAMBA_VERSION_STRING) < 0) {
4719 smb_panic("init_globals: ENOMEM");
4720 }
4721 string_set(&Globals.szServerString, s);
4722 SAFE_FREE(s);
4723 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4724 DEFAULT_MINOR_VERSION) < 0) {
4725 smb_panic("init_globals: ENOMEM");
4726 }
4727 string_set(&Globals.szAnnounceVersion, s);
4728 SAFE_FREE(s);
4729#ifdef DEVELOPER
4730 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4731#endif
4732
4733 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4734
4735 string_set(&Globals.szLogonDrive, "");
4736 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4737 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4738 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4739
4740 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4741 string_set(&Globals.szPasswordServer, "*");
4742
4743 Globals.AlgorithmicRidBase = BASE_RID;
4744
4745 Globals.bLoadPrinters = True;
4746 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4747
4748 Globals.ConfigBackend = config_backend;
4749
4750 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4751 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4752 Globals.max_xmit = 0x4104;
4753 Globals.max_mux = 50; /* This is *needed* for profile support. */
4754 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4755 Globals.bDisableSpoolss = False;
4756 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4757 Globals.pwordlevel = 0;
4758 Globals.unamelevel = 0;
4759 Globals.deadtime = 0;
4760 Globals.getwd_cache = true;
4761 Globals.bLargeReadwrite = True;
4762 Globals.max_log_size = 5000;
4763 Globals.max_open_files = MAX_OPEN_FILES;
4764 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4765 Globals.maxprotocol = PROTOCOL_NT1;
4766 Globals.minprotocol = PROTOCOL_CORE;
4767 Globals.security = SEC_USER;
4768 Globals.paranoid_server_security = True;
4769 Globals.bEncryptPasswords = True;
4770 Globals.bUpdateEncrypt = False;
4771 Globals.clientSchannel = Auto;
4772 Globals.serverSchannel = Auto;
4773 Globals.bReadRaw = True;
4774 Globals.bWriteRaw = True;
4775 Globals.bNullPasswords = False;
4776 Globals.bObeyPamRestrictions = False;
4777 Globals.syslog = 1;
4778 Globals.bSyslogOnly = False;
4779 Globals.bTimestampLogs = True;
4780 string_set(&Globals.szLogLevel, "0");
4781 Globals.bDebugPrefixTimestamp = False;
4782 Globals.bDebugHiresTimestamp = False;
4783 Globals.bDebugPid = False;
4784 Globals.bDebugUid = False;
4785 Globals.bDebugClass = False;
4786 Globals.bEnableCoreFiles = True;
4787 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4788 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4789 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4790 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4791 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4792 Globals.lm_interval = 60;
4793 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4794#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4795 Globals.bNISHomeMap = False;
4796#ifdef WITH_NISPLUS_HOME
4797 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4798#else
4799 string_set(&Globals.szNISHomeMapName, "auto.home");
4800#endif
4801#endif
4802 Globals.bTimeServer = False;
4803 Globals.bBindInterfacesOnly = False;
4804 Globals.bUnixPasswdSync = False;
4805 Globals.bPamPasswordChange = False;
4806 Globals.bPasswdChatDebug = False;
4807 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4808 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
4809 Globals.bNTStatusSupport = True; /* Use NT status by default. */
4810 Globals.bStatCache = True; /* use stat cache by default */
4811 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4812 Globals.restrict_anonymous = 0;
4813 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
4814 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
4815 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
4816 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4817 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
4818 /* Note, that we will use NTLM2 session security (which is different), if it is available */
4819
4820 Globals.map_to_guest = 0; /* By Default, "Never" */
4821 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4822 Globals.enhanced_browsing = true;
4823 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4824#ifdef MMAP_BLACKLIST
4825 Globals.bUseMmap = False;
4826#else
4827 Globals.bUseMmap = True;
4828#endif
4829 Globals.bUnixExtensions = True;
4830 Globals.bResetOnZeroVC = False;
4831
4832 /* hostname lookups can be very expensive and are broken on
4833 a large number of sites (tridge) */
4834 Globals.bHostnameLookups = False;
4835
4836 string_set(&Globals.szPassdbBackend, "smbpasswd");
4837 string_set(&Globals.szLdapSuffix, "");
4838 string_set(&Globals.szLdapMachineSuffix, "");
4839 string_set(&Globals.szLdapUserSuffix, "");
4840 string_set(&Globals.szLdapGroupSuffix, "");
4841 string_set(&Globals.szLdapIdmapSuffix, "");
4842
4843 string_set(&Globals.szLdapAdminDn, "");
4844 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4845 Globals.ldap_ssl_ads = False;
4846 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4847 Globals.ldap_delete_dn = False;
4848 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4849 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4850 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4851 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4852
4853 Globals.ldap_debug_level = 0;
4854 Globals.ldap_debug_threshold = 10;
4855
4856 /* This is what we tell the afs client. in reality we set the token
4857 * to never expire, though, when this runs out the afs client will
4858 * forget the token. Set to 0 to get NEVERDATE.*/
4859 Globals.iAfsTokenLifetime = 604800;
4860 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4861
4862/* these parameters are set to defaults that are more appropriate
4863 for the increasing samba install base:
4864
4865 as a member of the workgroup, that will possibly become a
4866 _local_ master browser (lm = True). this is opposed to a forced
4867 local master browser startup (pm = True).
4868
4869 doesn't provide WINS server service by default (wsupp = False),
4870 and doesn't provide domain master browser services by default, either.
4871
4872*/
4873
4874 Globals.bMsAddPrinterWizard = True;
4875 Globals.os_level = 20;
4876 Globals.bLocalMaster = True;
4877 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4878 Globals.bDomainLogons = False;
4879 Globals.bBrowseList = True;
4880 Globals.bWINSsupport = False;
4881 Globals.bWINSproxy = False;
4882
4883 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4884 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4885
4886 Globals.bDNSproxy = True;
4887
4888 /* this just means to use them if they exist */
4889 Globals.bKernelOplocks = True;
4890
4891 Globals.bAllowTrustedDomains = True;
4892 string_set(&Globals.szIdmapBackend, "tdb");
4893
4894 string_set(&Globals.szTemplateShell, "/bin/false");
4895 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4896 string_set(&Globals.szWinbindSeparator, "\\");
4897
4898 string_set(&Globals.szCupsServer, "");
4899 string_set(&Globals.szIPrintServer, "");
4900
4901 string_set(&Globals.ctdbdSocket, "");
4902 Globals.szClusterAddresses = NULL;
4903 Globals.clustering = False;
4904
4905 Globals.winbind_cache_time = 300; /* 5 minutes */
4906 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4907 Globals.bWinbindEnumUsers = False;
4908 Globals.bWinbindEnumGroups = False;
4909 Globals.bWinbindUseDefaultDomain = False;
4910 Globals.bWinbindTrustedDomainsOnly = False;
4911 Globals.bWinbindNestedGroups = True;
4912 Globals.winbind_expand_groups = 1;
4913 Globals.szWinbindNssInfo = str_list_make(talloc_autofree_context(), "template", NULL);
4914 Globals.bWinbindRefreshTickets = False;
4915 Globals.bWinbindOfflineLogon = False;
4916
4917 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4918 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4919
4920 Globals.bPassdbExpandExplicit = False;
4921
4922 Globals.name_cache_timeout = 660; /* In seconds */
4923
4924 Globals.bUseSpnego = True;
4925 Globals.bClientUseSpnego = True;
4926
4927 Globals.client_signing = Auto;
4928 Globals.server_signing = False;
4929
4930 Globals.bDeferSharingViolations = True;
4931 string_set(&Globals.smb_ports, SMB_PORTS);
4932
4933 Globals.bEnablePrivileges = True;
4934 Globals.bHostMSDfs = True;
4935 Globals.bASUSupport = False;
4936
4937 /* User defined shares. */
4938 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4939 smb_panic("init_globals: ENOMEM");
4940 }
4941 string_set(&Globals.szUsersharePath, s);
4942 SAFE_FREE(s);
4943 string_set(&Globals.szUsershareTemplateShare, "");
4944 Globals.iUsershareMaxShares = 0;
4945 /* By default disallow sharing of directories not owned by the sharer. */
4946 Globals.bUsershareOwnerOnly = True;
4947 /* By default disallow guest access to usershares. */
4948 Globals.bUsershareAllowGuests = False;
4949
4950 Globals.iKeepalive = DEFAULT_KEEPALIVE;
4951
4952 /* By default no shares out of the registry */
4953 Globals.bRegistryShares = False;
4954
4955 Globals.iminreceivefile = 0;
4956}
4957
4958/*******************************************************************
4959 Convenience routine to grab string parameters into temporary memory
4960 and run standard_sub_basic on them. The buffers can be written to by
4961 callers without affecting the source string.
4962********************************************************************/
4963
4964static char *lp_string(const char *s)
4965{
4966 char *ret;
4967 TALLOC_CTX *ctx = talloc_tos();
4968
4969 /* The follow debug is useful for tracking down memory problems
4970 especially if you have an inner loop that is calling a lp_*()
4971 function that returns a string. Perhaps this debug should be
4972 present all the time? */
4973
4974#if 0
4975 DEBUG(10, ("lp_string(%s)\n", s));
4976#endif
4977
4978 ret = talloc_sub_basic(ctx,
4979 get_current_username(),
4980 current_user_info.domain,
4981 s);
4982 if (trim_char(ret, '\"', '\"')) {
4983 if (strchr(ret,'\"') != NULL) {
4984 TALLOC_FREE(ret);
4985 ret = talloc_sub_basic(ctx,
4986 get_current_username(),
4987 current_user_info.domain,
4988 s);
4989 }
4990 }
4991 return ret;
4992}
4993
4994/*
4995 In this section all the functions that are used to access the
4996 parameters from the rest of the program are defined
4997*/
4998
4999#define FN_GLOBAL_STRING(fn_name,ptr) \
5000 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5001#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5002 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5003#define FN_GLOBAL_LIST(fn_name,ptr) \
5004 const char **fn_name(void) {return(*(const char ***)(ptr));}
5005#define FN_GLOBAL_BOOL(fn_name,ptr) \
5006 bool fn_name(void) {return(*(bool *)(ptr));}
5007#define FN_GLOBAL_CHAR(fn_name,ptr) \
5008 char fn_name(void) {return(*(char *)(ptr));}
5009#define FN_GLOBAL_INTEGER(fn_name,ptr) \
5010 int fn_name(void) {return(*(int *)(ptr));}
5011
5012#define FN_LOCAL_STRING(fn_name,val) \
5013 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5014#define FN_LOCAL_CONST_STRING(fn_name,val) \
5015 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5016#define FN_LOCAL_LIST(fn_name,val) \
5017 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5018#define FN_LOCAL_BOOL(fn_name,val) \
5019 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5020#define FN_LOCAL_INTEGER(fn_name,val) \
5021 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5022
5023#define FN_LOCAL_PARM_BOOL(fn_name,val) \
5024 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5025#define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5026 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5027#define FN_LOCAL_PARM_STRING(fn_name,val) \
5028 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));}
5029#define FN_LOCAL_CHAR(fn_name,val) \
5030 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5031
5032FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5033FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5034FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5035FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5036FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5037FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5038FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5039FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5040FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5041FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5042FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5043FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5044FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5045FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5046FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5047FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5048FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5049FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5050FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5051FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5052FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5053FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5054FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5055FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5056FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5057FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5058FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5059FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5060FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5061FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5062FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5063FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5064FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5065FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5066FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5067FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5068FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5069FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5070FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5071FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5072FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5073FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5074FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5075FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5076FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5077FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5078static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5079FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5080/* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5081 * lp_passdb_backend() should be replace by the this macro again after
5082 * some releases.
5083 * */
5084const char *lp_passdb_backend(void)
5085{
5086 char *delim, *quote;
5087
5088 delim = strchr( Globals.szPassdbBackend, ' ');
5089 /* no space at all */
5090 if (delim == NULL) {
5091 goto out;
5092 }
5093
5094 quote = strchr(Globals.szPassdbBackend, '"');
5095 /* no quote char or non in the first part */
5096 if (quote == NULL || quote > delim) {
5097 *delim = '\0';
5098 goto warn;
5099 }
5100
5101 quote = strchr(quote+1, '"');
5102 if (quote == NULL) {
5103 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5104 goto out;
5105 } else if (*(quote+1) == '\0') {
5106 /* space, fitting quote char, and one backend only */
5107 goto out;
5108 } else {
5109 /* terminate string after the fitting quote char */
5110 *(quote+1) = '\0';
5111 }
5112
5113warn:
5114 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5115 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5116 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5117 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5118
5119out:
5120 return Globals.szPassdbBackend;
5121}
5122FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5123FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5124FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5125FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5126FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5127
5128FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5129FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5130FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5131FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5132FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5133FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5134
5135FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5136
5137FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5138FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5139FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5140
5141FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5142
5143FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5144FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5145FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5146FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5147FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5148FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5149FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5150FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5151FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5152FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5153FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5154FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5155FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5156FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5157FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5158
5159FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5160FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5161FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5162FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5163FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5164FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5165
5166FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5167FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5168FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5169FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5170FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5171FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5172FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5173FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5174FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5175FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5176FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5177FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5178FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5179FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5180FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5181FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5182FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5183FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5184
5185FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5186
5187FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5188FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5189FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5190FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5191FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5192FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5193FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5194FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5195FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5196FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5197FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5198FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5199FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5200FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5201FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5202FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5203FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5204FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5205FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5206FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5207FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5208FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5209FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5210FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5211FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5212FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5213FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5214FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5215FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5216FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5217FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5218FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5219FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5220FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5221static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5222FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5223FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5224FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5225FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5226FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5227FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5228FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5229FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5230FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5231FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5232FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5233FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5234FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5235FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5236FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5237FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5238FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5239FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5240FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5241FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5242FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5243FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5244FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5245FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5246FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5247FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5248FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab)
5249FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5250FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5251FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5252FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5253FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5254FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5255FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5256FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5257FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5258FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5259FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5260FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5261FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5262FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5263FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5264FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5265FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5266FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5267FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5268FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5269FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5270FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5271FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5272FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5273FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5274FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5275static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5276FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5277FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5278FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5279FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5280FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5281FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5282FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5283FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5284FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5285
5286FN_LOCAL_STRING(lp_preexec, szPreExec)
5287FN_LOCAL_STRING(lp_postexec, szPostExec)
5288FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5289FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5290FN_LOCAL_STRING(lp_servicename, szService)
5291FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5292FN_LOCAL_STRING(lp_pathname, szPath)
5293FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5294FN_LOCAL_STRING(lp_username, szUsername)
5295FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5296FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5297FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5298FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5299FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5300FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5301FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5302FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5303FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5304FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5305FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5306FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5307FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5308FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5309FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5310FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5311FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5312FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5313static FN_LOCAL_STRING(_lp_printername, szPrintername)
5314FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5315FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5316FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5317FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5318FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5319FN_LOCAL_STRING(lp_comment, comment)
5320FN_LOCAL_STRING(lp_force_user, force_user)
5321FN_LOCAL_STRING(lp_force_group, force_group)
5322FN_LOCAL_LIST(lp_readlist, readlist)
5323FN_LOCAL_LIST(lp_writelist, writelist)
5324FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5325FN_LOCAL_STRING(lp_fstype, fstype)
5326FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5327FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5328static FN_LOCAL_STRING(lp_volume, volume)
5329FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5330FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5331FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5332FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5333FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5334FN_LOCAL_STRING(lp_dfree_command, szDfree)
5335FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5336FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5337FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5338FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5339FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5340FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5341FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5342FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5343FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5344FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5345FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5346FN_LOCAL_BOOL(lp_readonly, bRead_only)
5347FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5348FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5349FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5350FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5351FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5352FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5353FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5354FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5355FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5356FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5357FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5358FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5359FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5360FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5361FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5362FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5363FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
5364FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
5365FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
5366FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
5367FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
5368FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
5369FN_LOCAL_BOOL(lp_map_system, bMap_system)
5370FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
5371FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
5372FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
5373FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
5374FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
5375FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
5376FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
5377FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
5378FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
5379FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
5380FN_LOCAL_BOOL(lp_inherit_owner, bInheritOwner)
5381FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
5382FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
5383FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
5384FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
5385FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
5386FN_LOCAL_BOOL(lp_ea_support, bEASupport)
5387FN_LOCAL_BOOL(_lp_use_sendfile, bUseSendfile)
5388FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
5389FN_LOCAL_BOOL(lp_map_acl_inherit, bMap_acl_inherit)
5390FN_LOCAL_BOOL(lp_afs_share, bAfs_Share)
5391FN_LOCAL_BOOL(lp_acl_check_permissions, bAclCheckPermissions)
5392FN_LOCAL_BOOL(lp_acl_group_control, bAclGroupControl)
5393FN_LOCAL_BOOL(lp_acl_map_full_control, bAclMapFullControl)
5394FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
5395FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
5396FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
5397FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
5398FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
5399FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
5400FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
5401FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
5402FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
5403FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
5404FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
5405FN_LOCAL_INTEGER(lp_printing, iPrinting)
5406FN_LOCAL_INTEGER(lp_max_reported_jobs, iMaxReportedPrintJobs)
5407FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
5408FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
5409FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
5410FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
5411FN_LOCAL_INTEGER(lp_dfree_cache_time, iDfreeCacheTime)
5412FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
5413FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
5414FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
5415FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
5416FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
5417FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
5418FN_LOCAL_CHAR(lp_magicchar, magic_char)
5419FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
5420FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
5421FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
5422FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
5423FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
5424FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
5425FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
5426FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
5427
5428/* local prototypes */
5429
5430static int map_parameter(const char *pszParmName);
5431static int map_parameter_canonical(const char *pszParmName, bool *inverse);
5432static bool set_boolean(bool *pb, const char *pszParmValue);
5433static const char *get_boolean(bool bool_value);
5434static int getservicebyname(const char *pszServiceName,
5435 struct service *pserviceDest);
5436static void copy_service(struct service *pserviceDest,
5437 struct service *pserviceSource,
5438 struct bitmap *pcopymapDest);
5439static bool do_parameter(const char *pszParmName, const char *pszParmValue,
5440 void *userdata);
5441static bool do_section(const char *pszSectionName, void *userdata);
5442static void init_copymap(struct service *pservice);
5443static bool hash_a_service(const char *name, int number);
5444static void free_service_byindex(int iService);
5445static char * canonicalize_servicename(const char *name);
5446static void show_parameter(int parmIndex);
5447static bool is_synonym_of(int parm1, int parm2, bool *inverse);
5448
5449/*
5450 * This is a helper function for parametrical options support. It returns a
5451 * pointer to parametrical option value if it exists or NULL otherwise. Actual
5452 * parametrical functions are quite simple
5453 */
5454static struct param_opt_struct *get_parametrics(int snum, const char *type,
5455 const char *option)
5456{
5457 bool global_section = False;
5458 char* param_key;
5459 struct param_opt_struct *data;
5460
5461 if (snum >= iNumServices) return NULL;
5462
5463 if (snum < 0) {
5464 data = Globals.param_opt;
5465 global_section = True;
5466 } else {
5467 data = ServicePtrs[snum]->param_opt;
5468 }
5469
5470 if (asprintf(&param_key, "%s:%s", type, option) == -1) {
5471 DEBUG(0,("asprintf failed!\n"));
5472 return NULL;
5473 }
5474
5475 while (data) {
5476 if (strwicmp(data->key, param_key) == 0) {
5477 string_free(&param_key);
5478 return data;
5479 }
5480 data = data->next;
5481 }
5482
5483 if (!global_section) {
5484 /* Try to fetch the same option but from globals */
5485 /* but only if we are not already working with Globals */
5486 data = Globals.param_opt;
5487 while (data) {
5488 if (strwicmp(data->key, param_key) == 0) {
5489 string_free(&param_key);
5490 return data;
5491 }
5492 data = data->next;
5493 }
5494 }
5495
5496 string_free(&param_key);
5497
5498 return NULL;
5499}
5500
5501
5502#define MISSING_PARAMETER(name) \
5503 DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
5504
5505/*******************************************************************
5506convenience routine to return int parameters.
5507********************************************************************/
5508static int lp_int(const char *s)
5509{
5510
5511 if (!s || !*s) {
5512 MISSING_PARAMETER(lp_int);
5513 return (-1);
5514 }
5515
5516 return (int)strtol(s, NULL, 0);
5517}
5518
5519/*******************************************************************
5520convenience routine to return unsigned long parameters.
5521********************************************************************/
5522static unsigned long lp_ulong(const char *s)
5523{
5524
5525 if (!s || !*s) {
5526 MISSING_PARAMETER(lp_ulong);
5527 return (0);
5528 }
5529
5530 return strtoul(s, NULL, 0);
5531}
5532
5533/*******************************************************************
5534convenience routine to return boolean parameters.
5535********************************************************************/
5536static bool lp_bool(const char *s)
5537{
5538 bool ret = False;
5539
5540 if (!s || !*s) {
5541 MISSING_PARAMETER(lp_bool);
5542 return False;
5543 }
5544
5545 if (!set_boolean(&ret,s)) {
5546 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
5547 return False;
5548 }
5549
5550 return ret;
5551}
5552
5553/*******************************************************************
5554convenience routine to return enum parameters.
5555********************************************************************/
5556static int lp_enum(const char *s,const struct enum_list *_enum)
5557{
5558 int i;
5559
5560 if (!s || !*s || !_enum) {
5561 MISSING_PARAMETER(lp_enum);
5562 return (-1);
5563 }
5564
5565 for (i=0; _enum[i].name; i++) {
5566 if (strequal(_enum[i].name,s))
5567 return _enum[i].value;
5568 }
5569
5570 DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
5571 return (-1);
5572}
5573
5574#undef MISSING_PARAMETER
5575
5576/* DO NOT USE lp_parm_string ANYMORE!!!!
5577 * use lp_parm_const_string or lp_parm_talloc_string
5578 *
5579 * lp_parm_string is only used to let old modules find this symbol
5580 */
5581#undef lp_parm_string
5582 char *lp_parm_string(const char *servicename, const char *type, const char *option);
5583 char *lp_parm_string(const char *servicename, const char *type, const char *option)
5584{
5585 return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
5586}
5587
5588/* Return parametric option from a given service. Type is a part of option before ':' */
5589/* Parametric option has following syntax: 'Type: option = value' */
5590/* the returned value is talloced on the talloc_tos() */
5591char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
5592{
5593 struct param_opt_struct *data = get_parametrics(snum, type, option);
5594
5595 if (data == NULL||data->value==NULL) {
5596 if (def) {
5597 return lp_string(def);
5598 } else {
5599 return NULL;
5600 }
5601 }
5602
5603 return lp_string(data->value);
5604}
5605
5606/* Return parametric option from a given service. Type is a part of option before ':' */
5607/* Parametric option has following syntax: 'Type: option = value' */
5608const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
5609{
5610 struct param_opt_struct *data = get_parametrics(snum, type, option);
5611
5612 if (data == NULL||data->value==NULL)
5613 return def;
5614
5615 return data->value;
5616}
5617
5618/* Return parametric option from a given service. Type is a part of option before ':' */
5619/* Parametric option has following syntax: 'Type: option = value' */
5620
5621const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
5622{
5623 struct param_opt_struct *data = get_parametrics(snum, type, option);
5624
5625 if (data == NULL||data->value==NULL)
5626 return (const char **)def;
5627
5628 if (data->list==NULL) {
5629 data->list = str_list_make(talloc_autofree_context(), data->value, NULL);
5630 }
5631
5632 return (const char **)data->list;
5633}
5634
5635/* Return parametric option from a given service. Type is a part of option before ':' */
5636/* Parametric option has following syntax: 'Type: option = value' */
5637
5638int lp_parm_int(int snum, const char *type, const char *option, int def)
5639{
5640 struct param_opt_struct *data = get_parametrics(snum, type, option);
5641
5642 if (data && data->value && *data->value)
5643 return lp_int(data->value);
5644
5645 return def;
5646}
5647
5648/* Return parametric option from a given service. Type is a part of option before ':' */
5649/* Parametric option has following syntax: 'Type: option = value' */
5650
5651unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
5652{
5653 struct param_opt_struct *data = get_parametrics(snum, type, option);
5654
5655 if (data && data->value && *data->value)
5656 return lp_ulong(data->value);
5657
5658 return def;
5659}
5660
5661/* Return parametric option from a given service. Type is a part of option before ':' */
5662/* Parametric option has following syntax: 'Type: option = value' */
5663
5664bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
5665{
5666 struct param_opt_struct *data = get_parametrics(snum, type, option);
5667
5668 if (data && data->value && *data->value)
5669 return lp_bool(data->value);
5670
5671 return def;
5672}
5673
5674/* Return parametric option from a given service. Type is a part of option before ':' */
5675/* Parametric option has following syntax: 'Type: option = value' */
5676
5677int lp_parm_enum(int snum, const char *type, const char *option,
5678 const struct enum_list *_enum, int def)
5679{
5680 struct param_opt_struct *data = get_parametrics(snum, type, option);
5681
5682 if (data && data->value && *data->value && _enum)
5683 return lp_enum(data->value, _enum);
5684
5685 return def;
5686}
5687
5688
5689/***************************************************************************
5690 Initialise a service to the defaults.
5691***************************************************************************/
5692
5693static void init_service(struct service *pservice)
5694{
5695 memset((char *)pservice, '\0', sizeof(struct service));
5696 copy_service(pservice, &sDefault, NULL);
5697}
5698
5699/***************************************************************************
5700 Free the dynamically allocated parts of a service struct.
5701***************************************************************************/
5702
5703static void free_service(struct service *pservice)
5704{
5705 int i;
5706 struct param_opt_struct *data, *pdata;
5707 if (!pservice)
5708 return;
5709
5710 if (pservice->szService)
5711 DEBUG(5, ("free_service: Freeing service %s\n",
5712 pservice->szService));
5713
5714 string_free(&pservice->szService);
5715 bitmap_free(pservice->copymap);
5716
5717 for (i = 0; parm_table[i].label; i++) {
5718 if ((parm_table[i].type == P_STRING ||
5719 parm_table[i].type == P_USTRING) &&
5720 parm_table[i].p_class == P_LOCAL)
5721 string_free((char **)
5722 (((char *)pservice) +
5723 PTR_DIFF(parm_table[i].ptr, &sDefault)));
5724 else if (parm_table[i].type == P_LIST &&
5725 parm_table[i].p_class == P_LOCAL)
5726 TALLOC_FREE(*((char ***)
5727 (((char *)pservice) +
5728 PTR_DIFF(parm_table[i].ptr,
5729 &sDefault))));
5730 }
5731
5732 data = pservice->param_opt;
5733 if (data)
5734 DEBUG(5,("Freeing parametrics:\n"));
5735 while (data) {
5736 DEBUG(5,("[%s = %s]\n", data->key, data->value));
5737 string_free(&data->key);
5738 string_free(&data->value);
5739 TALLOC_FREE(data->list);
5740 pdata = data->next;
5741 SAFE_FREE(data);
5742 data = pdata;
5743 }
5744
5745 ZERO_STRUCTP(pservice);
5746}
5747
5748
5749/***************************************************************************
5750 remove a service indexed in the ServicePtrs array from the ServiceHash
5751 and free the dynamically allocated parts
5752***************************************************************************/
5753
5754static void free_service_byindex(int idx)
5755{
5756 if ( !LP_SNUM_OK(idx) )
5757 return;
5758
5759 ServicePtrs[idx]->valid = False;
5760 invalid_services[num_invalid_services++] = idx;
5761
5762 /* we have to cleanup the hash record */
5763
5764 if (ServicePtrs[idx]->szService) {
5765 char *canon_name = canonicalize_servicename(
5766 ServicePtrs[idx]->szService );
5767
5768 dbwrap_delete_bystring(ServiceHash, canon_name );
5769 TALLOC_FREE(canon_name);
5770 }
5771
5772 free_service(ServicePtrs[idx]);
5773}
5774
5775/***************************************************************************
5776 Add a new service to the services array initialising it with the given
5777 service.
5778***************************************************************************/
5779
5780static int add_a_service(const struct service *pservice, const char *name)
5781{
5782 int i;
5783 struct service tservice;
5784 int num_to_alloc = iNumServices + 1;
5785 struct param_opt_struct *data, *pdata;
5786
5787 tservice = *pservice;
5788
5789 /* it might already exist */
5790 if (name) {
5791 i = getservicebyname(name, NULL);
5792 if (i >= 0) {
5793 /* Clean all parametric options for service */
5794 /* They will be added during parsing again */
5795 data = ServicePtrs[i]->param_opt;
5796 while (data) {
5797 string_free(&data->key);
5798 string_free(&data->value);
5799 TALLOC_FREE(data->list);
5800 pdata = data->next;
5801 SAFE_FREE(data);
5802 data = pdata;
5803 }
5804 ServicePtrs[i]->param_opt = NULL;
5805 return (i);
5806 }
5807 }
5808
5809 /* find an invalid one */
5810 i = iNumServices;
5811 if (num_invalid_services > 0) {
5812 i = invalid_services[--num_invalid_services];
5813 }
5814
5815 /* if not, then create one */
5816 if (i == iNumServices) {
5817 struct service **tsp;
5818 int *tinvalid;
5819
5820 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
5821 if (tsp == NULL) {
5822 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
5823 return (-1);
5824 }
5825 ServicePtrs = tsp;
5826 ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
5827 if (!ServicePtrs[iNumServices]) {
5828 DEBUG(0,("add_a_service: out of memory!\n"));
5829 return (-1);
5830 }
5831 iNumServices++;
5832
5833 /* enlarge invalid_services here for now... */
5834 tinvalid = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(invalid_services, int,
5835 num_to_alloc);
5836 if (tinvalid == NULL) {
5837 DEBUG(0,("add_a_service: failed to enlarge "
5838 "invalid_services!\n"));
5839 return (-1);
5840 }
5841 invalid_services = tinvalid;
5842 } else {
5843 free_service_byindex(i);
5844 }
5845
5846 ServicePtrs[i]->valid = True;
5847
5848 init_service(ServicePtrs[i]);
5849 copy_service(ServicePtrs[i], &tservice, NULL);
5850 if (name)
5851 string_set(&ServicePtrs[i]->szService, name);
5852
5853 DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
5854 i, ServicePtrs[i]->szService));
5855
5856 if (!hash_a_service(ServicePtrs[i]->szService, i)) {
5857 return (-1);
5858 }
5859
5860 return (i);
5861}
5862
5863/***************************************************************************
5864 Convert a string to uppercase and remove whitespaces.
5865***************************************************************************/
5866
5867static char *canonicalize_servicename(const char *src)
5868{
5869 char *result;
5870
5871 if ( !src ) {
5872 DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
5873 return NULL;
5874 }
5875
5876 result = talloc_strdup(talloc_tos(), src);
5877 SMB_ASSERT(result != NULL);
5878
5879 strlower_m(result);
5880 return result;
5881}
5882
5883/***************************************************************************
5884 Add a name/index pair for the services array to the hash table.
5885***************************************************************************/
5886
5887static bool hash_a_service(const char *name, int idx)
5888{
5889 char *canon_name;
5890
5891 if ( !ServiceHash ) {
5892 DEBUG(10,("hash_a_service: creating servicehash\n"));
5893 ServiceHash = db_open_rbt(NULL);
5894 if ( !ServiceHash ) {
5895 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
5896 return False;
5897 }
5898 }
5899
5900 DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
5901 idx, name));
5902
5903 canon_name = canonicalize_servicename( name );
5904
5905 dbwrap_store_bystring(ServiceHash, canon_name,
5906 make_tdb_data((uint8 *)&idx, sizeof(idx)),
5907 TDB_REPLACE);
5908
5909 TALLOC_FREE(canon_name);
5910
5911 return True;
5912}
5913
5914/***************************************************************************
5915 Add a new home service, with the specified home directory, defaults coming
5916 from service ifrom.
5917***************************************************************************/
5918
5919bool lp_add_home(const char *pszHomename, int iDefaultService,
5920 const char *user, const char *pszHomedir)
5921{
5922 int i;
5923
5924 if (pszHomename == NULL || user == NULL || pszHomedir == NULL ||
5925 pszHomedir[0] == '\0') {
5926 return false;
5927 }
5928
5929 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
5930
5931 if (i < 0)
5932 return (False);
5933
5934 if (!(*(ServicePtrs[iDefaultService]->szPath))
5935 || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
5936 string_set(&ServicePtrs[i]->szPath, pszHomedir);
5937 }
5938
5939 if (!(*(ServicePtrs[i]->comment))) {
5940 char *comment = NULL;
5941 if (asprintf(&comment, "Home directory of %s", user) < 0) {
5942 return false;
5943 }
5944 string_set(&ServicePtrs[i]->comment, comment);
5945 SAFE_FREE(comment);
5946 }
5947
5948 /* set the browseable flag from the global default */
5949
5950 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
5951
5952 ServicePtrs[i]->autoloaded = True;
5953
5954 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
5955 user, ServicePtrs[i]->szPath ));
5956
5957 return (True);
5958}
5959
5960/***************************************************************************
5961 Add a new service, based on an old one.
5962***************************************************************************/
5963
5964int lp_add_service(const char *pszService, int iDefaultService)
5965{
5966 if (iDefaultService < 0) {
5967 return add_a_service(&sDefault, pszService);
5968 }
5969
5970 return (add_a_service(ServicePtrs[iDefaultService], pszService));
5971}
5972
5973/***************************************************************************
5974 Add the IPC service.
5975***************************************************************************/
5976
5977static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
5978{
5979 char *comment = NULL;
5980 int i = add_a_service(&sDefault, ipc_name);
5981
5982 if (i < 0)
5983 return (False);
5984
5985 if (asprintf(&comment, "IPC Service (%s)",
5986 Globals.szServerString) < 0) {
5987 return (False);
5988 }
5989
5990 string_set(&ServicePtrs[i]->szPath, tmpdir());
5991 string_set(&ServicePtrs[i]->szUsername, "");
5992 string_set(&ServicePtrs[i]->comment, comment);
5993 string_set(&ServicePtrs[i]->fstype, "IPC");
5994 ServicePtrs[i]->iMaxConnections = 0;
5995 ServicePtrs[i]->bAvailable = True;
5996 ServicePtrs[i]->bRead_only = True;
5997 ServicePtrs[i]->bGuest_only = False;
5998 ServicePtrs[i]->bAdministrative_share = True;
5999 ServicePtrs[i]->bGuest_ok = guest_ok;
6000 ServicePtrs[i]->bPrint_ok = False;
6001 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6002
6003 DEBUG(3, ("adding IPC service\n"));
6004
6005 SAFE_FREE(comment);
6006 return (True);
6007}
6008
6009/***************************************************************************
6010 Add a new printer service, with defaults coming from service iFrom.
6011***************************************************************************/
6012
6013bool lp_add_printer(const char *pszPrintername, int iDefaultService)
6014{
6015 const char *comment = "From Printcap";
6016 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
6017
6018 if (i < 0)
6019 return (False);
6020
6021 /* note that we do NOT default the availability flag to True - */
6022 /* we take it from the default service passed. This allows all */
6023 /* dynamic printers to be disabled by disabling the [printers] */
6024 /* entry (if/when the 'available' keyword is implemented!). */
6025
6026 /* the printer name is set to the service name. */
6027 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
6028 string_set(&ServicePtrs[i]->comment, comment);
6029
6030 /* set the browseable flag from the gloabl default */
6031 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
6032
6033 /* Printers cannot be read_only. */
6034 ServicePtrs[i]->bRead_only = False;
6035 /* No share modes on printer services. */
6036 ServicePtrs[i]->bShareModes = False;
6037 /* No oplocks on printer services. */
6038 ServicePtrs[i]->bOpLocks = False;
6039 /* Printer services must be printable. */
6040 ServicePtrs[i]->bPrint_ok = True;
6041
6042 DEBUG(3, ("adding printer service %s\n", pszPrintername));
6043
6044 return (True);
6045}
6046
6047
6048/***************************************************************************
6049 Check whether the given parameter name is valid.
6050 Parametric options (names containing a colon) are considered valid.
6051***************************************************************************/
6052
6053bool lp_parameter_is_valid(const char *pszParmName)
6054{
6055 return ((map_parameter(pszParmName) != -1) ||
6056 (strchr(pszParmName, ':') != NULL));
6057}
6058
6059/***************************************************************************
6060 Check whether the given name is the name of a global parameter.
6061 Returns True for strings belonging to parameters of class
6062 P_GLOBAL, False for all other strings, also for parametric options
6063 and strings not belonging to any option.
6064***************************************************************************/
6065
6066bool lp_parameter_is_global(const char *pszParmName)
6067{
6068 int num = map_parameter(pszParmName);
6069
6070 if (num >= 0) {
6071 return (parm_table[num].p_class == P_GLOBAL);
6072 }
6073
6074 return False;
6075}
6076
6077/**************************************************************************
6078 Check whether the given name is the canonical name of a parameter.
6079 Returns False if it is not a valid parameter Name.
6080 For parametric options, True is returned.
6081**************************************************************************/
6082
6083bool lp_parameter_is_canonical(const char *parm_name)
6084{
6085 if (!lp_parameter_is_valid(parm_name)) {
6086 return False;
6087 }
6088
6089 return (map_parameter(parm_name) ==
6090 map_parameter_canonical(parm_name, NULL));
6091}
6092
6093/**************************************************************************
6094 Determine the canonical name for a parameter.
6095 Indicate when it is an inverse (boolean) synonym instead of a
6096 "usual" synonym.
6097**************************************************************************/
6098
6099bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
6100 bool *inverse)
6101{
6102 int num;
6103
6104 if (!lp_parameter_is_valid(parm_name)) {
6105 *canon_parm = NULL;
6106 return False;
6107 }
6108
6109 num = map_parameter_canonical(parm_name, inverse);
6110 if (num < 0) {
6111 /* parametric option */
6112 *canon_parm = parm_name;
6113 } else {
6114 *canon_parm = parm_table[num].label;
6115 }
6116
6117 return True;
6118
6119}
6120
6121/**************************************************************************
6122 Determine the canonical name for a parameter.
6123 Turn the value given into the inverse boolean expression when
6124 the synonym is an invers boolean synonym.
6125
6126 Return True if parm_name is a valid parameter name and
6127 in case it is an invers boolean synonym, if the val string could
6128 successfully be converted to the reverse bool.
6129 Return false in all other cases.
6130**************************************************************************/
6131
6132bool lp_canonicalize_parameter_with_value(const char *parm_name,
6133 const char *val,
6134 const char **canon_parm,
6135 const char **canon_val)
6136{
6137 int num;
6138 bool inverse;
6139
6140 if (!lp_parameter_is_valid(parm_name)) {
6141 *canon_parm = NULL;
6142 *canon_val = NULL;
6143 return False;
6144 }
6145
6146 num = map_parameter_canonical(parm_name, &inverse);
6147 if (num < 0) {
6148 /* parametric option */
6149 *canon_parm = parm_name;
6150 *canon_val = val;
6151 } else {
6152 *canon_parm = parm_table[num].label;
6153 if (inverse) {
6154 if (!lp_invert_boolean(val, canon_val)) {
6155 *canon_val = NULL;
6156 return False;
6157 }
6158 } else {
6159 *canon_val = val;
6160 }
6161 }
6162
6163 return True;
6164}
6165
6166/***************************************************************************
6167 Map a parameter's string representation to something we can use.
6168 Returns False if the parameter string is not recognised, else TRUE.
6169***************************************************************************/
6170
6171static int map_parameter(const char *pszParmName)
6172{
6173 int iIndex;
6174
6175 if (*pszParmName == '-' && !strequal(pszParmName, "-valid"))
6176 return (-1);
6177
6178 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
6179 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
6180 return (iIndex);
6181
6182 /* Warn only if it isn't parametric option */
6183 if (strchr(pszParmName, ':') == NULL)
6184 DEBUG(1, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
6185 /* We do return 'fail' for parametric options as well because they are
6186 stored in different storage
6187 */
6188 return (-1);
6189}
6190
6191/***************************************************************************
6192 Map a parameter's string representation to the index of the canonical
6193 form of the parameter (it might be a synonym).
6194 Returns -1 if the parameter string is not recognised.
6195***************************************************************************/
6196
6197static int map_parameter_canonical(const char *pszParmName, bool *inverse)
6198{
6199 int parm_num, canon_num;
6200 bool loc_inverse = False;
6201
6202 parm_num = map_parameter(pszParmName);
6203 if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
6204 /* invalid, parametric or no canidate for synonyms ... */
6205 goto done;
6206 }
6207
6208 for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
6209 if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
6210 parm_num = canon_num;
6211 goto done;
6212 }
6213 }
6214
6215done:
6216 if (inverse != NULL) {
6217 *inverse = loc_inverse;
6218 }
6219 return parm_num;
6220}
6221
6222/***************************************************************************
6223 return true if parameter number parm1 is a synonym of parameter
6224 number parm2 (parm2 being the principal name).
6225 set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
6226 False otherwise.
6227***************************************************************************/
6228
6229static bool is_synonym_of(int parm1, int parm2, bool *inverse)
6230{
6231 if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
6232 (parm_table[parm1].flags & FLAG_HIDE) &&
6233 !(parm_table[parm2].flags & FLAG_HIDE))
6234 {
6235 if (inverse != NULL) {
6236 if ((parm_table[parm1].type == P_BOOLREV) &&
6237 (parm_table[parm2].type == P_BOOL))
6238 {
6239 *inverse = True;
6240 } else {
6241 *inverse = False;
6242 }
6243 }
6244 return True;
6245 }
6246 return False;
6247}
6248
6249/***************************************************************************
6250 Show one parameter's name, type, [values,] and flags.
6251 (helper functions for show_parameter_list)
6252***************************************************************************/
6253
6254static void show_parameter(int parmIndex)
6255{
6256 int enumIndex, flagIndex;
6257 int parmIndex2;
6258 bool hadFlag;
6259 bool hadSyn;
6260 bool inverse;
6261 const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
6262 "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
6263 "P_ENUM", "P_SEP"};
6264 unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
6265 FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
6266 FLAG_HIDE, FLAG_DOS_STRING};
6267 const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
6268 "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
6269 "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
6270
6271 printf("%s=%s", parm_table[parmIndex].label,
6272 type[parm_table[parmIndex].type]);
6273 if (parm_table[parmIndex].type == P_ENUM) {
6274 printf(",");
6275 for (enumIndex=0;
6276 parm_table[parmIndex].enum_list[enumIndex].name;
6277 enumIndex++)
6278 {
6279 printf("%s%s",
6280 enumIndex ? "|" : "",
6281 parm_table[parmIndex].enum_list[enumIndex].name);
6282 }
6283 }
6284 printf(",");
6285 hadFlag = False;
6286 for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
6287 if (parm_table[parmIndex].flags & flags[flagIndex]) {
6288 printf("%s%s",
6289 hadFlag ? "|" : "",
6290 flag_names[flagIndex]);
6291 hadFlag = True;
6292 }
6293 }
6294
6295 /* output synonyms */
6296 hadSyn = False;
6297 for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
6298 if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
6299 printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
6300 parm_table[parmIndex2].label);
6301 } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
6302 if (!hadSyn) {
6303 printf(" (synonyms: ");
6304 hadSyn = True;
6305 } else {
6306 printf(", ");
6307 }
6308 printf("%s%s", parm_table[parmIndex2].label,
6309 inverse ? "[i]" : "");
6310 }
6311 }
6312 if (hadSyn) {
6313 printf(")");
6314 }
6315
6316 printf("\n");
6317}
6318
6319/***************************************************************************
6320 Show all parameter's name, type, [values,] and flags.
6321***************************************************************************/
6322
6323void show_parameter_list(void)
6324{
6325 int classIndex, parmIndex;
6326 const char *section_names[] = { "local", "global", NULL};
6327
6328 for (classIndex=0; section_names[classIndex]; classIndex++) {
6329 printf("[%s]\n", section_names[classIndex]);
6330 for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
6331 if (parm_table[parmIndex].p_class == classIndex) {
6332 show_parameter(parmIndex);
6333 }
6334 }
6335 }
6336}
6337
6338/***************************************************************************
6339 Set a boolean variable from the text value stored in the passed string.
6340 Returns True in success, False if the passed string does not correctly
6341 represent a boolean.
6342***************************************************************************/
6343
6344static bool set_boolean(bool *pb, const char *pszParmValue)
6345{
6346 bool bRetval;
6347 bool value;
6348
6349 bRetval = True;
6350 value = False;
6351 if (strwicmp(pszParmValue, "yes") == 0 ||
6352 strwicmp(pszParmValue, "true") == 0 ||
6353 strwicmp(pszParmValue, "1") == 0)
6354 value = True;
6355 else if (strwicmp(pszParmValue, "no") == 0 ||
6356 strwicmp(pszParmValue, "False") == 0 ||
6357 strwicmp(pszParmValue, "0") == 0)
6358 value = False;
6359 else {
6360 DEBUG(2,
6361 ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
6362 pszParmValue));
6363 bRetval = False;
6364 }
6365
6366 if ((pb != NULL) && (bRetval != False)) {
6367 *pb = value;
6368 }
6369
6370 return (bRetval);
6371}
6372
6373
6374/***************************************************************************
6375 Check if a given string correctly represents a boolean value.
6376***************************************************************************/
6377
6378bool lp_string_is_valid_boolean(const char *parm_value)
6379{
6380 return set_boolean(NULL, parm_value);
6381}
6382
6383/***************************************************************************
6384 Get the standard string representation of a boolean value ("yes" or "no")
6385***************************************************************************/
6386
6387static const char *get_boolean(bool bool_value)
6388{
6389 static const char *yes_str = "yes";
6390 static const char *no_str = "no";
6391
6392 return (bool_value ? yes_str : no_str);
6393}
6394
6395/***************************************************************************
6396 Provide the string of the negated boolean value associated to the boolean
6397 given as a string. Returns False if the passed string does not correctly
6398 represent a boolean.
6399***************************************************************************/
6400
6401bool lp_invert_boolean(const char *str, const char **inverse_str)
6402{
6403 bool val;
6404
6405 if (!set_boolean(&val, str)) {
6406 return False;
6407 }
6408
6409 *inverse_str = get_boolean(!val);
6410 return True;
6411}
6412
6413/***************************************************************************
6414 Provide the canonical string representation of a boolean value given
6415 as a string. Return True on success, False if the string given does
6416 not correctly represent a boolean.
6417***************************************************************************/
6418
6419bool lp_canonicalize_boolean(const char *str, const char**canon_str)
6420{
6421 bool val;
6422
6423 if (!set_boolean(&val, str)) {
6424 return False;
6425 }
6426
6427 *canon_str = get_boolean(val);
6428 return True;
6429}
6430
6431/***************************************************************************
6432Find a service by name. Otherwise works like get_service.
6433***************************************************************************/
6434
6435static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
6436{
6437 int iService = -1;
6438 char *canon_name;
6439 TDB_DATA data;
6440
6441 if (ServiceHash == NULL) {
6442 return -1;
6443 }
6444
6445 canon_name = canonicalize_servicename(pszServiceName);
6446
6447 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
6448
6449 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
6450 iService = *(int *)data.dptr;
6451 }
6452
6453 TALLOC_FREE(canon_name);
6454
6455 if ((iService != -1) && (LP_SNUM_OK(iService))
6456 && (pserviceDest != NULL)) {
6457 copy_service(pserviceDest, ServicePtrs[iService], NULL);
6458 }
6459
6460 return (iService);
6461}
6462
6463/***************************************************************************
6464 Copy a service structure to another.
6465 If pcopymapDest is NULL then copy all fields
6466***************************************************************************/
6467
6468static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
6469 struct bitmap *pcopymapDest)
6470{
6471 int i;
6472 bool bcopyall = (pcopymapDest == NULL);
6473 struct param_opt_struct *data, *pdata, *paramo;
6474 bool not_added;
6475
6476 for (i = 0; parm_table[i].label; i++)
6477 if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
6478 (bcopyall || bitmap_query(pcopymapDest,i))) {
6479 void *def_ptr = parm_table[i].ptr;
6480 void *src_ptr =
6481 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
6482 &sDefault);
6483 void *dest_ptr =
6484 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
6485 &sDefault);
6486
6487 switch (parm_table[i].type) {
6488 case P_BOOL:
6489 case P_BOOLREV:
6490 *(bool *)dest_ptr = *(bool *)src_ptr;
6491 break;
6492
6493 case P_INTEGER:
6494 case P_ENUM:
6495 case P_OCTAL:
6496 *(int *)dest_ptr = *(int *)src_ptr;
6497 break;
6498
6499 case P_CHAR:
6500 *(char *)dest_ptr = *(char *)src_ptr;
6501 break;
6502
6503 case P_STRING:
6504 string_set((char **)dest_ptr,
6505 *(char **)src_ptr);
6506 break;
6507
6508 case P_USTRING:
6509 string_set((char **)dest_ptr,
6510 *(char **)src_ptr);
6511 strupper_m(*(char **)dest_ptr);
6512 break;
6513 case P_LIST:
6514 TALLOC_FREE(*((char ***)dest_ptr));
6515 str_list_copy(NULL, (char ***)dest_ptr,
6516 *(const char ***)src_ptr);
6517 break;
6518 default:
6519 break;
6520 }
6521 }
6522
6523 if (bcopyall) {
6524 init_copymap(pserviceDest);
6525 if (pserviceSource->copymap)
6526 bitmap_copy(pserviceDest->copymap,
6527 pserviceSource->copymap);
6528 }
6529
6530 data = pserviceSource->param_opt;
6531 while (data) {
6532 not_added = True;
6533 pdata = pserviceDest->param_opt;
6534 /* Traverse destination */
6535 while (pdata) {
6536 /* If we already have same option, override it */
6537 if (strwicmp(pdata->key, data->key) == 0) {
6538 string_free(&pdata->value);
6539 TALLOC_FREE(data->list);
6540 pdata->value = SMB_STRDUP(data->value);
6541 not_added = False;
6542 break;
6543 }
6544 pdata = pdata->next;
6545 }
6546 if (not_added) {
6547 paramo = SMB_XMALLOC_P(struct param_opt_struct);
6548 paramo->key = SMB_STRDUP(data->key);
6549 paramo->value = SMB_STRDUP(data->value);
6550 paramo->list = NULL;
6551 DLIST_ADD(pserviceDest->param_opt, paramo);
6552 }
6553 data = data->next;
6554 }
6555}
6556
6557/***************************************************************************
6558Check a service for consistency. Return False if the service is in any way
6559incomplete or faulty, else True.
6560***************************************************************************/
6561
6562bool service_ok(int iService)
6563{
6564 bool bRetval;
6565
6566 bRetval = True;
6567 if (ServicePtrs[iService]->szService[0] == '\0') {
6568 DEBUG(0, ("The following message indicates an internal error:\n"));
6569 DEBUG(0, ("No service name in service entry.\n"));
6570 bRetval = False;
6571 }
6572
6573 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
6574 /* I can't see why you'd want a non-printable printer service... */
6575 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
6576 if (!ServicePtrs[iService]->bPrint_ok) {
6577 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
6578 ServicePtrs[iService]->szService));
6579 ServicePtrs[iService]->bPrint_ok = True;
6580 }
6581 /* [printers] service must also be non-browsable. */
6582 if (ServicePtrs[iService]->bBrowseable)
6583 ServicePtrs[iService]->bBrowseable = False;
6584 }
6585
6586 if (ServicePtrs[iService]->szPath[0] == '\0' &&
6587 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0 &&
6588 ServicePtrs[iService]->szMSDfsProxy[0] == '\0'
6589 ) {
6590 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
6591 ServicePtrs[iService]->szService));
6592 ServicePtrs[iService]->bAvailable = False;
6593 }
6594
6595 /* If a service is flagged unavailable, log the fact at level 1. */
6596 if (!ServicePtrs[iService]->bAvailable)
6597 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
6598 ServicePtrs[iService]->szService));
6599
6600 return (bRetval);
6601}
6602
6603static struct smbconf_ctx *lp_smbconf_ctx(void)
6604{
6605 WERROR werr;
6606 static struct smbconf_ctx *conf_ctx = NULL;
6607
6608 if (conf_ctx == NULL) {
6609 werr = smbconf_init(NULL, &conf_ctx, "registry:");
6610 if (!W_ERROR_IS_OK(werr)) {
6611 DEBUG(1, ("error initializing registry configuration: "
6612 "%s\n", dos_errstr(werr)));
6613 conf_ctx = NULL;
6614 }
6615 }
6616
6617 return conf_ctx;
6618}
6619
6620static bool process_registry_service(struct smbconf_service *service)
6621{
6622 uint32_t count;
6623 bool ret;
6624
6625 if (service == NULL) {
6626 return false;
6627 }
6628
6629 ret = do_section(service->name, NULL);
6630 if (ret != true) {
6631 return false;
6632 }
6633 for (count = 0; count < service->num_params; count++) {
6634 ret = do_parameter(service->param_names[count],
6635 service->param_values[count],
6636 NULL);
6637 if (ret != true) {
6638 return false;
6639 }
6640 }
6641 if (iServiceIndex >= 0) {
6642 return service_ok(iServiceIndex);
6643 }
6644 return true;
6645}
6646
6647/*
6648 * process_registry_globals
6649 */
6650static bool process_registry_globals(void)
6651{
6652 WERROR werr;
6653 struct smbconf_service *service = NULL;
6654 TALLOC_CTX *mem_ctx = talloc_stackframe();
6655 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6656 bool ret = false;
6657
6658 if (conf_ctx == NULL) {
6659 goto done;
6660 }
6661
6662 add_to_file_list(INCLUDE_REGISTRY_NAME, INCLUDE_REGISTRY_NAME);
6663
6664 ret = do_parameter("registry shares", "yes", NULL);
6665 if (!ret) {
6666 goto done;
6667 }
6668
6669 if (!smbconf_share_exists(conf_ctx, GLOBAL_NAME)) {
6670 /* nothing to read from the registry yet but make sure lp_load
6671 * doesn't return false */
6672 ret = true;
6673 goto done;
6674 }
6675
6676 werr = smbconf_get_share(conf_ctx, mem_ctx, GLOBAL_NAME, &service);
6677 if (!W_ERROR_IS_OK(werr)) {
6678 goto done;
6679 }
6680
6681 ret = process_registry_service(service);
6682 if (!ret) {
6683 goto done;
6684 }
6685
6686 /* store the csn */
6687 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6688
6689done:
6690 TALLOC_FREE(mem_ctx);
6691 return ret;
6692}
6693
6694static bool process_registry_shares(void)
6695{
6696 WERROR werr;
6697 uint32_t count;
6698 struct smbconf_service **service = NULL;
6699 uint32_t num_shares = 0;
6700 TALLOC_CTX *mem_ctx = talloc_stackframe();
6701 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6702 bool ret = false;
6703
6704 if (conf_ctx == NULL) {
6705 goto done;
6706 }
6707
6708 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
6709 if (!W_ERROR_IS_OK(werr)) {
6710 goto done;
6711 }
6712
6713 ret = true;
6714
6715 for (count = 0; count < num_shares; count++) {
6716 if (strequal(service[count]->name, GLOBAL_NAME)) {
6717 continue;
6718 }
6719 ret = process_registry_service(service[count]);
6720 if (!ret) {
6721 goto done;
6722 }
6723 }
6724
6725 /* store the csn */
6726 smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
6727
6728done:
6729 TALLOC_FREE(mem_ctx);
6730 return ret;
6731}
6732
6733#define MAX_INCLUDE_DEPTH 100
6734
6735static uint8_t include_depth;
6736
6737static struct file_lists {
6738 struct file_lists *next;
6739 char *name;
6740 char *subfname;
6741 time_t modtime;
6742} *file_lists = NULL;
6743
6744/*******************************************************************
6745 Keep a linked list of all config files so we know when one has changed
6746 it's date and needs to be reloaded.
6747********************************************************************/
6748
6749static void add_to_file_list(const char *fname, const char *subfname)
6750{
6751 struct file_lists *f = file_lists;
6752
6753 while (f) {
6754 if (f->name && !strcmp(f->name, fname))
6755 break;
6756 f = f->next;
6757 }
6758
6759 if (!f) {
6760 f = SMB_MALLOC_P(struct file_lists);
6761 if (!f)
6762 return;
6763 f->next = file_lists;
6764 f->name = SMB_STRDUP(fname);
6765 if (!f->name) {
6766 SAFE_FREE(f);
6767 return;
6768 }
6769 f->subfname = SMB_STRDUP(subfname);
6770 if (!f->subfname) {
6771 SAFE_FREE(f);
6772 return;
6773 }
6774 file_lists = f;
6775 f->modtime = file_modtime(subfname);
6776 } else {
6777 time_t t = file_modtime(subfname);
6778 if (t)
6779 f->modtime = t;
6780 }
6781}
6782
6783/**
6784 * Utility function for outsiders to check if we're running on registry.
6785 */
6786bool lp_config_backend_is_registry(void)
6787{
6788 return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
6789}
6790
6791/**
6792 * Utility function to check if the config backend is FILE.
6793 */
6794bool lp_config_backend_is_file(void)
6795{
6796 return (lp_config_backend() == CONFIG_BACKEND_FILE);
6797}
6798
6799/*******************************************************************
6800 Check if a config file has changed date.
6801********************************************************************/
6802
6803bool lp_file_list_changed(void)
6804{
6805 struct file_lists *f = file_lists;
6806
6807 DEBUG(6, ("lp_file_list_changed()\n"));
6808
6809 while (f) {
6810 char *n2 = NULL;
6811 time_t mod_time;
6812
6813 if (strequal(f->name, INCLUDE_REGISTRY_NAME)) {
6814 struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
6815
6816 if (conf_ctx == NULL) {
6817 return false;
6818 }
6819 if (smbconf_changed(conf_ctx, &conf_last_csn, NULL,
6820 NULL))
6821 {
6822 DEBUGADD(6, ("registry config changed\n"));
6823 return true;
6824 }
6825 } else {
6826 n2 = alloc_sub_basic(get_current_username(),
6827 current_user_info.domain,
6828 f->name);
6829 if (!n2) {
6830 return false;
6831 }
6832 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
6833 f->name, n2, ctime(&f->modtime)));
6834
6835 mod_time = file_modtime(n2);
6836
6837 if (mod_time &&
6838 ((f->modtime != mod_time) ||
6839 (f->subfname == NULL) ||
6840 (strcmp(n2, f->subfname) != 0)))
6841 {
6842 DEBUGADD(6,
6843 ("file %s modified: %s\n", n2,
6844 ctime(&mod_time)));
6845 f->modtime = mod_time;
6846 SAFE_FREE(f->subfname);
6847 f->subfname = n2; /* Passing ownership of
6848 return from alloc_sub_basic
6849 above. */
6850 return true;
6851 }
6852 SAFE_FREE(n2);
6853 }
6854 f = f->next;
6855 }
6856 return (False);
6857}
6858
6859
6860/***************************************************************************
6861 Run standard_sub_basic on netbios name... needed because global_myname
6862 is not accessed through any lp_ macro.
6863 Note: We must *NOT* use string_set() here as ptr points to global_myname.
6864***************************************************************************/
6865
6866static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
6867{
6868 bool ret;
6869 char *netbios_name = alloc_sub_basic(get_current_username(),
6870 current_user_info.domain,
6871 pszParmValue);
6872
6873 ret = set_global_myname(netbios_name);
6874 SAFE_FREE(netbios_name);
6875 string_set(&Globals.szNetbiosName,global_myname());
6876
6877 DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
6878 global_myname()));
6879
6880 return ret;
6881}
6882
6883static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
6884{
6885 if (strcmp(*ptr, pszParmValue) != 0) {
6886 string_set(ptr, pszParmValue);
6887 init_iconv();
6888 }
6889 return True;
6890}
6891
6892
6893
6894static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
6895{
6896 bool ret;
6897
6898 ret = set_global_myworkgroup(pszParmValue);
6899 string_set(&Globals.szWorkgroup,lp_workgroup());
6900
6901 return ret;
6902}
6903
6904static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
6905{
6906 bool ret;
6907
6908 ret = set_global_scope(pszParmValue);
6909 string_set(&Globals.szNetbiosScope,global_scope());
6910
6911 return ret;
6912}
6913
6914static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
6915{
6916 TALLOC_FREE(Globals.szNetbiosAliases);
6917 Globals.szNetbiosAliases = str_list_make(talloc_autofree_context(), pszParmValue, NULL);
6918 return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
6919}
6920
6921/***************************************************************************
6922 Handle the include operation.
6923***************************************************************************/
6924static bool bAllowIncludeRegistry = true;
6925
6926static bool handle_include(int snum, const char *pszParmValue, char **ptr)
6927{
6928 char *fname;
6929
6930 if (include_depth >= MAX_INCLUDE_DEPTH) {
6931 DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
6932 include_depth));
6933 return false;
6934 }
6935
6936 if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
6937 if (!bAllowIncludeRegistry) {
6938 return true;
6939 }
6940 if (bInGlobalSection) {
6941 bool ret;
6942 include_depth++;
6943 ret = process_registry_globals();
6944 include_depth--;
6945 return ret;
6946 } else {
6947 DEBUG(1, ("\"include = registry\" only effective "
6948 "in %s section\n", GLOBAL_NAME));
6949 return false;
6950 }
6951 }
6952
6953 fname = alloc_sub_basic(get_current_username(),
6954 current_user_info.domain,
6955 pszParmValue);
6956
6957 add_to_file_list(pszParmValue, fname);
6958
6959 string_set(ptr, fname);
6960
6961 if (file_exist(fname, NULL)) {
6962 bool ret;
6963 include_depth++;
6964 ret = pm_process(fname, do_section, do_parameter, NULL);
6965 include_depth--;
6966 SAFE_FREE(fname);
6967 return ret;
6968 }
6969
6970 DEBUG(2, ("Can't find include file %s\n", fname));
6971 SAFE_FREE(fname);
6972 return true;
6973}
6974
6975/***************************************************************************
6976 Handle the interpretation of the copy parameter.
6977***************************************************************************/
6978
6979static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
6980{
6981 bool bRetval;
6982 int iTemp;
6983 struct service serviceTemp;
6984
6985 string_set(ptr, pszParmValue);
6986
6987 init_service(&serviceTemp);
6988
6989 bRetval = False;
6990
6991 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
6992
6993 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
6994 if (iTemp == iServiceIndex) {
6995 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
6996 } else {
6997 copy_service(ServicePtrs[iServiceIndex],
6998 &serviceTemp,
6999 ServicePtrs[iServiceIndex]->copymap);
7000 bRetval = True;
7001 }
7002 } else {
7003 DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
7004 bRetval = False;
7005 }
7006
7007 free_service(&serviceTemp);
7008 return (bRetval);
7009}
7010
7011static bool handle_ldap_debug_level(int snum, const char *pszParmValue, char **ptr)
7012{
7013 Globals.ldap_debug_level = lp_int(pszParmValue);
7014 init_ldap_debugging();
7015 return true;
7016}
7017
7018/***************************************************************************
7019 Handle idmap/non unix account uid and gid allocation parameters. The format of these
7020 parameters is:
7021
7022 [global]
7023
7024 idmap uid = 1000-1999
7025 idmap gid = 700-899
7026
7027 We only do simple parsing checks here. The strings are parsed into useful
7028 structures in the idmap daemon code.
7029
7030***************************************************************************/
7031
7032/* Some lp_ routines to return idmap [ug]id information */
7033
7034static uid_t idmap_uid_low, idmap_uid_high;
7035static gid_t idmap_gid_low, idmap_gid_high;
7036
7037bool lp_idmap_uid(uid_t *low, uid_t *high)
7038{
7039 if (idmap_uid_low == 0 || idmap_uid_high == 0)
7040 return False;
7041
7042 if (low)
7043 *low = idmap_uid_low;
7044
7045 if (high)
7046 *high = idmap_uid_high;
7047
7048 return True;
7049}
7050
7051bool lp_idmap_gid(gid_t *low, gid_t *high)
7052{
7053 if (idmap_gid_low == 0 || idmap_gid_high == 0)
7054 return False;
7055
7056 if (low)
7057 *low = idmap_gid_low;
7058
7059 if (high)
7060 *high = idmap_gid_high;
7061
7062 return True;
7063}
7064
7065/* Do some simple checks on "idmap [ug]id" parameter values */
7066
7067static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
7068{
7069 uint32 low, high;
7070
7071 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7072 return False;
7073
7074 /* Parse OK */
7075
7076 string_set(ptr, pszParmValue);
7077
7078 idmap_uid_low = low;
7079 idmap_uid_high = high;
7080
7081 return True;
7082}
7083
7084static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
7085{
7086 uint32 low, high;
7087
7088 if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
7089 return False;
7090
7091 /* Parse OK */
7092
7093 string_set(ptr, pszParmValue);
7094
7095 idmap_gid_low = low;
7096 idmap_gid_high = high;
7097
7098 return True;
7099}
7100
7101/***************************************************************************
7102 Handle the DEBUG level list.
7103***************************************************************************/
7104
7105static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
7106{
7107 string_set(ptr, pszParmValueIn);
7108 return debug_parse_levels(pszParmValueIn);
7109}
7110
7111/***************************************************************************
7112 Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
7113***************************************************************************/
7114
7115static const char *append_ldap_suffix( const char *str )
7116{
7117 const char *suffix_string;
7118
7119
7120 suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
7121 Globals.szLdapSuffix );
7122 if ( !suffix_string ) {
7123 DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
7124 return "";
7125 }
7126
7127 return suffix_string;
7128}
7129
7130const char *lp_ldap_machine_suffix(void)
7131{
7132 if (Globals.szLdapMachineSuffix[0])
7133 return append_ldap_suffix(Globals.szLdapMachineSuffix);
7134
7135 return lp_string(Globals.szLdapSuffix);
7136}
7137
7138const char *lp_ldap_user_suffix(void)
7139{
7140 if (Globals.szLdapUserSuffix[0])
7141 return append_ldap_suffix(Globals.szLdapUserSuffix);
7142
7143 return lp_string(Globals.szLdapSuffix);
7144}
7145
7146const char *lp_ldap_group_suffix(void)
7147{
7148 if (Globals.szLdapGroupSuffix[0])
7149 return append_ldap_suffix(Globals.szLdapGroupSuffix);
7150
7151 return lp_string(Globals.szLdapSuffix);
7152}
7153
7154const char *lp_ldap_idmap_suffix(void)
7155{
7156 if (Globals.szLdapIdmapSuffix[0])
7157 return append_ldap_suffix(Globals.szLdapIdmapSuffix);
7158
7159 return lp_string(Globals.szLdapSuffix);
7160}
7161
7162/****************************************************************************
7163 set the value for a P_ENUM
7164 ***************************************************************************/
7165
7166static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
7167 int *ptr )
7168{
7169 int i;
7170
7171 for (i = 0; parm->enum_list[i].name; i++) {
7172 if ( strequal(pszParmValue, parm->enum_list[i].name)) {
7173 *ptr = parm->enum_list[i].value;
7174 return;
7175 }
7176 }
7177 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
7178 pszParmValue, parm->label));
7179}
7180
7181/***************************************************************************
7182***************************************************************************/
7183
7184static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
7185{
7186 static int parm_num = -1;
7187 struct service *s;
7188
7189 if ( parm_num == -1 )
7190 parm_num = map_parameter( "printing" );
7191
7192 lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr );
7193
7194 if ( snum < 0 )
7195 s = &sDefault;
7196 else
7197 s = ServicePtrs[snum];
7198
7199 init_printer_values( s );
7200
7201 return True;
7202}
7203
7204
7205/***************************************************************************
7206 Initialise a copymap.
7207***************************************************************************/
7208
7209static void init_copymap(struct service *pservice)
7210{
7211 int i;
7212 if (pservice->copymap) {
7213 bitmap_free(pservice->copymap);
7214 }
7215 pservice->copymap = bitmap_allocate(NUMPARAMETERS);
7216 if (!pservice->copymap)
7217 DEBUG(0,
7218 ("Couldn't allocate copymap!! (size %d)\n",
7219 (int)NUMPARAMETERS));
7220 else
7221 for (i = 0; i < NUMPARAMETERS; i++)
7222 bitmap_set(pservice->copymap, i);
7223}
7224
7225/***************************************************************************
7226 Return the local pointer to a parameter given the service number and the
7227 pointer into the default structure.
7228***************************************************************************/
7229
7230void *lp_local_ptr(int snum, void *ptr)
7231{
7232 return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
7233}
7234
7235/***************************************************************************
7236 Process a parameter for a particular service number. If snum < 0
7237 then assume we are in the globals.
7238***************************************************************************/
7239
7240bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
7241{
7242 int parmnum, i;
7243 void *parm_ptr = NULL; /* where we are going to store the result */
7244 void *def_ptr = NULL;
7245 struct param_opt_struct *paramo, *data;
7246 bool not_added;
7247
7248 parmnum = map_parameter(pszParmName);
7249
7250 if (parmnum < 0) {
7251 TALLOC_CTX *frame;
7252
7253 if (strchr(pszParmName, ':') == NULL) {
7254 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
7255 pszParmName));
7256 return (True);
7257 }
7258
7259 /*
7260 * We've got a parametric option
7261 */
7262
7263 frame = talloc_stackframe();
7264
7265 not_added = True;
7266 data = (snum < 0)
7267 ? Globals.param_opt : ServicePtrs[snum]->param_opt;
7268 /* Traverse destination */
7269 while (data) {
7270 /* If we already have same option, override it */
7271 if (strwicmp(data->key, pszParmName) == 0) {
7272 string_free(&data->value);
7273 TALLOC_FREE(data->list);
7274 data->value = SMB_STRDUP(pszParmValue);
7275 not_added = False;
7276 break;
7277 }
7278 data = data->next;
7279 }
7280 if (not_added) {
7281 paramo = SMB_XMALLOC_P(struct param_opt_struct);
7282 paramo->key = SMB_STRDUP(pszParmName);
7283 paramo->value = SMB_STRDUP(pszParmValue);
7284 paramo->list = NULL;
7285 if (snum < 0) {
7286 DLIST_ADD(Globals.param_opt, paramo);
7287 } else {
7288 DLIST_ADD(ServicePtrs[snum]->param_opt,
7289 paramo);
7290 }
7291 }
7292
7293 TALLOC_FREE(frame);
7294 return (True);
7295 }
7296
7297 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
7298 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
7299 pszParmName));
7300 }
7301
7302 def_ptr = parm_table[parmnum].ptr;
7303
7304 /* we might point at a service, the default service or a global */
7305 if (snum < 0) {
7306 parm_ptr = def_ptr;
7307 } else {
7308 if (parm_table[parmnum].p_class == P_GLOBAL) {
7309 DEBUG(0,
7310 ("Global parameter %s found in service section!\n",
7311 pszParmName));
7312 return (True);
7313 }
7314 parm_ptr =
7315 ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
7316 &sDefault);
7317 }
7318
7319 if (snum >= 0) {
7320 if (!ServicePtrs[snum]->copymap)
7321 init_copymap(ServicePtrs[snum]);
7322
7323 /* this handles the aliases - set the copymap for other entries with
7324 the same data pointer */
7325 for (i = 0; parm_table[i].label; i++)
7326 if (parm_table[i].ptr == parm_table[parmnum].ptr)
7327 bitmap_clear(ServicePtrs[snum]->copymap, i);
7328 }
7329
7330 /* if it is a special case then go ahead */
7331 if (parm_table[parmnum].special) {
7332 return parm_table[parmnum].special(snum, pszParmValue,
7333 (char **)parm_ptr);
7334 }
7335
7336 /* now switch on the type of variable it is */
7337 switch (parm_table[parmnum].type)
7338 {
7339 case P_BOOL:
7340 *(bool *)parm_ptr = lp_bool(pszParmValue);
7341 break;
7342
7343 case P_BOOLREV:
7344 *(bool *)parm_ptr = !lp_bool(pszParmValue);
7345 break;
7346
7347 case P_INTEGER:
7348 *(int *)parm_ptr = lp_int(pszParmValue);
7349 break;
7350
7351 case P_CHAR:
7352 *(char *)parm_ptr = *pszParmValue;
7353 break;
7354
7355 case P_OCTAL:
7356 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
7357 if ( i != 1 ) {
7358 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
7359 }
7360 break;
7361
7362 case P_LIST:
7363 TALLOC_FREE(*((char ***)parm_ptr));
7364 *(char ***)parm_ptr = str_list_make(
7365 talloc_autofree_context(), pszParmValue, NULL);
7366 break;
7367
7368 case P_STRING:
7369 string_set((char **)parm_ptr, pszParmValue);
7370 break;
7371
7372 case P_USTRING:
7373 string_set((char **)parm_ptr, pszParmValue);
7374 strupper_m(*(char **)parm_ptr);
7375 break;
7376
7377 case P_ENUM:
7378 lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
7379 break;
7380 case P_SEP:
7381 break;
7382 }
7383
7384 return (True);
7385}
7386
7387/***************************************************************************
7388 Process a parameter.
7389***************************************************************************/
7390
7391static bool do_parameter(const char *pszParmName, const char *pszParmValue,
7392 void *userdata)
7393{
7394 if (!bInGlobalSection && bGlobalOnly)
7395 return (True);
7396
7397 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
7398
7399 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
7400 pszParmName, pszParmValue));
7401}
7402
7403/***************************************************************************
7404 Print a parameter of the specified type.
7405***************************************************************************/
7406
7407static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
7408{
7409 int i;
7410 switch (p->type)
7411 {
7412 case P_ENUM:
7413 for (i = 0; p->enum_list[i].name; i++) {
7414 if (*(int *)ptr == p->enum_list[i].value) {
7415 fprintf(f, "%s",
7416 p->enum_list[i].name);
7417 break;
7418 }
7419 }
7420 break;
7421
7422 case P_BOOL:
7423 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
7424 break;
7425
7426 case P_BOOLREV:
7427 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
7428 break;
7429
7430 case P_INTEGER:
7431 fprintf(f, "%d", *(int *)ptr);
7432 break;
7433
7434 case P_CHAR:
7435 fprintf(f, "%c", *(char *)ptr);
7436 break;
7437
7438 case P_OCTAL: {
7439 char *o = octal_string(*(int *)ptr);
7440 fprintf(f, "%s", o);
7441 TALLOC_FREE(o);
7442 break;
7443 }
7444
7445 case P_LIST:
7446 if ((char ***)ptr && *(char ***)ptr) {
7447 char **list = *(char ***)ptr;
7448 for (; *list; list++) {
7449 /* surround strings with whitespace in double quotes */
7450 if ( strchr_m( *list, ' ' ) )
7451 fprintf(f, "\"%s\"%s", *list, ((*(list+1))?", ":""));
7452 else
7453 fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
7454 }
7455 }
7456 break;
7457
7458 case P_STRING:
7459 case P_USTRING:
7460 if (*(char **)ptr) {
7461 fprintf(f, "%s", *(char **)ptr);
7462 }
7463 break;
7464 case P_SEP:
7465 break;
7466 }
7467}
7468
7469/***************************************************************************
7470 Check if two parameters are equal.
7471***************************************************************************/
7472
7473static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
7474{
7475 switch (type) {
7476 case P_BOOL:
7477 case P_BOOLREV:
7478 return (*((bool *)ptr1) == *((bool *)ptr2));
7479
7480 case P_INTEGER:
7481 case P_ENUM:
7482 case P_OCTAL:
7483 return (*((int *)ptr1) == *((int *)ptr2));
7484
7485 case P_CHAR:
7486 return (*((char *)ptr1) == *((char *)ptr2));
7487
7488 case P_LIST:
7489 return str_list_compare(*(char ***)ptr1, *(char ***)ptr2);
7490
7491 case P_STRING:
7492 case P_USTRING:
7493 {
7494 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
7495 if (p1 && !*p1)
7496 p1 = NULL;
7497 if (p2 && !*p2)
7498 p2 = NULL;
7499 return (p1 == p2 || strequal(p1, p2));
7500 }
7501 case P_SEP:
7502 break;
7503 }
7504 return (False);
7505}
7506
7507/***************************************************************************
7508 Initialize any local varients in the sDefault table.
7509***************************************************************************/
7510
7511void init_locals(void)
7512{
7513 /* None as yet. */
7514}
7515
7516/***************************************************************************
7517 Process a new section (service). At this stage all sections are services.
7518 Later we'll have special sections that permit server parameters to be set.
7519 Returns True on success, False on failure.
7520***************************************************************************/
7521
7522static bool do_section(const char *pszSectionName, void *userdata)
7523{
7524 bool bRetval;
7525 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
7526 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
7527 bRetval = False;
7528
7529 /* if we were in a global section then do the local inits */
7530 if (bInGlobalSection && !isglobal)
7531 init_locals();
7532
7533 /* if we've just struck a global section, note the fact. */
7534 bInGlobalSection = isglobal;
7535
7536 /* check for multiple global sections */
7537 if (bInGlobalSection) {
7538 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
7539 return (True);
7540 }
7541
7542 if (!bInGlobalSection && bGlobalOnly)
7543 return (True);
7544
7545 /* if we have a current service, tidy it up before moving on */
7546 bRetval = True;
7547
7548 if (iServiceIndex >= 0)
7549 bRetval = service_ok(iServiceIndex);
7550
7551 /* if all is still well, move to the next record in the services array */
7552 if (bRetval) {
7553 /* We put this here to avoid an odd message order if messages are */
7554 /* issued by the post-processing of a previous section. */
7555 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
7556
7557 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
7558 < 0) {
7559 DEBUG(0, ("Failed to add a new service\n"));
7560 return (False);
7561 }
7562 }
7563
7564 return (bRetval);
7565}
7566
7567
7568/***************************************************************************
7569 Determine if a partcular base parameter is currentl set to the default value.
7570***************************************************************************/
7571
7572static bool is_default(int i)
7573{
7574 if (!defaults_saved)
7575 return False;
7576 switch (parm_table[i].type) {
7577 case P_LIST:
7578 return str_list_compare (parm_table[i].def.lvalue,
7579 *(char ***)parm_table[i].ptr);
7580 case P_STRING:
7581 case P_USTRING:
7582 return strequal(parm_table[i].def.svalue,
7583 *(char **)parm_table[i].ptr);
7584 case P_BOOL:
7585 case P_BOOLREV:
7586 return parm_table[i].def.bvalue ==
7587 *(bool *)parm_table[i].ptr;
7588 case P_CHAR:
7589 return parm_table[i].def.cvalue ==
7590 *(char *)parm_table[i].ptr;
7591 case P_INTEGER:
7592 case P_OCTAL:
7593 case P_ENUM:
7594 return parm_table[i].def.ivalue ==
7595 *(int *)parm_table[i].ptr;
7596 case P_SEP:
7597 break;
7598 }
7599 return False;
7600}
7601
7602/***************************************************************************
7603Display the contents of the global structure.
7604***************************************************************************/
7605
7606static void dump_globals(FILE *f)
7607{
7608 int i;
7609 struct param_opt_struct *data;
7610
7611 fprintf(f, "[global]\n");
7612
7613 for (i = 0; parm_table[i].label; i++)
7614 if (parm_table[i].p_class == P_GLOBAL &&
7615 parm_table[i].ptr &&
7616 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
7617 if (defaults_saved && is_default(i))
7618 continue;
7619 fprintf(f, "\t%s = ", parm_table[i].label);
7620 print_parameter(&parm_table[i], parm_table[i].ptr, f);
7621 fprintf(f, "\n");
7622 }
7623 if (Globals.param_opt != NULL) {
7624 data = Globals.param_opt;
7625 while(data) {
7626 fprintf(f, "\t%s = %s\n", data->key, data->value);
7627 data = data->next;
7628 }
7629 }
7630
7631}
7632
7633/***************************************************************************
7634 Return True if a local parameter is currently set to the global default.
7635***************************************************************************/
7636
7637bool lp_is_default(int snum, struct parm_struct *parm)
7638{
7639 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
7640
7641 return equal_parameter(parm->type,
7642 ((char *)ServicePtrs[snum]) + pdiff,
7643 ((char *)&sDefault) + pdiff);
7644}
7645
7646/***************************************************************************
7647 Display the contents of a single services record.
7648***************************************************************************/
7649
7650static void dump_a_service(struct service *pService, FILE * f)
7651{
7652 int i;
7653 struct param_opt_struct *data;
7654
7655 if (pService != &sDefault)
7656 fprintf(f, "[%s]\n", pService->szService);
7657
7658 for (i = 0; parm_table[i].label; i++) {
7659
7660 if (parm_table[i].p_class == P_LOCAL &&
7661 parm_table[i].ptr &&
7662 (*parm_table[i].label != '-') &&
7663 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7664 {
7665
7666 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
7667
7668 if (pService == &sDefault) {
7669 if (defaults_saved && is_default(i))
7670 continue;
7671 } else {
7672 if (equal_parameter(parm_table[i].type,
7673 ((char *)pService) +
7674 pdiff,
7675 ((char *)&sDefault) +
7676 pdiff))
7677 continue;
7678 }
7679
7680 fprintf(f, "\t%s = ", parm_table[i].label);
7681 print_parameter(&parm_table[i],
7682 ((char *)pService) + pdiff, f);
7683 fprintf(f, "\n");
7684 }
7685 }
7686
7687 if (pService->param_opt != NULL) {
7688 data = pService->param_opt;
7689 while(data) {
7690 fprintf(f, "\t%s = %s\n", data->key, data->value);
7691 data = data->next;
7692 }
7693 }
7694}
7695
7696/***************************************************************************
7697 Display the contents of a parameter of a single services record.
7698***************************************************************************/
7699
7700bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
7701{
7702 int i;
7703 bool result = False;
7704 parm_class p_class;
7705 unsigned flag = 0;
7706 fstring local_parm_name;
7707 char *parm_opt;
7708 const char *parm_opt_value;
7709
7710 /* check for parametrical option */
7711 fstrcpy( local_parm_name, parm_name);
7712 parm_opt = strchr( local_parm_name, ':');
7713
7714 if (parm_opt) {
7715 *parm_opt = '\0';
7716 parm_opt++;
7717 if (strlen(parm_opt)) {
7718 parm_opt_value = lp_parm_const_string( snum,
7719 local_parm_name, parm_opt, NULL);
7720 if (parm_opt_value) {
7721 printf( "%s\n", parm_opt_value);
7722 result = True;
7723 }
7724 }
7725 return result;
7726 }
7727
7728 /* check for a key and print the value */
7729 if (isGlobal) {
7730 p_class = P_GLOBAL;
7731 flag = FLAG_GLOBAL;
7732 } else
7733 p_class = P_LOCAL;
7734
7735 for (i = 0; parm_table[i].label; i++) {
7736 if (strwicmp(parm_table[i].label, parm_name) == 0 &&
7737 (parm_table[i].p_class == p_class || parm_table[i].flags & flag) &&
7738 parm_table[i].ptr &&
7739 (*parm_table[i].label != '-') &&
7740 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7741 {
7742 void *ptr;
7743
7744 if (isGlobal) {
7745 ptr = parm_table[i].ptr;
7746 } else {
7747 struct service *pService = ServicePtrs[snum];
7748 ptr = ((char *)pService) +
7749 PTR_DIFF(parm_table[i].ptr, &sDefault);
7750 }
7751
7752 print_parameter(&parm_table[i],
7753 ptr, f);
7754 fprintf(f, "\n");
7755 result = True;
7756 break;
7757 }
7758 }
7759
7760 return result;
7761}
7762
7763/***************************************************************************
7764 Return info about the requested parameter (given as a string).
7765 Return NULL when the string is not a valid parameter name.
7766***************************************************************************/
7767
7768struct parm_struct *lp_get_parameter(const char *param_name)
7769{
7770 int num = map_parameter(param_name);
7771
7772 if (num < 0) {
7773 return NULL;
7774 }
7775
7776 return &parm_table[num];
7777}
7778
7779/***************************************************************************
7780 Return info about the next parameter in a service.
7781 snum==GLOBAL_SECTION_SNUM gives the globals.
7782 Return NULL when out of parameters.
7783***************************************************************************/
7784
7785struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
7786{
7787 if (snum < 0) {
7788 /* do the globals */
7789 for (; parm_table[*i].label; (*i)++) {
7790 if (parm_table[*i].p_class == P_SEPARATOR)
7791 return &parm_table[(*i)++];
7792
7793 if (!parm_table[*i].ptr
7794 || (*parm_table[*i].label == '-'))
7795 continue;
7796
7797 if ((*i) > 0
7798 && (parm_table[*i].ptr ==
7799 parm_table[(*i) - 1].ptr))
7800 continue;
7801
7802 if (is_default(*i) && !allparameters)
7803 continue;
7804
7805 return &parm_table[(*i)++];
7806 }
7807 } else {
7808 struct service *pService = ServicePtrs[snum];
7809
7810 for (; parm_table[*i].label; (*i)++) {
7811 if (parm_table[*i].p_class == P_SEPARATOR)
7812 return &parm_table[(*i)++];
7813
7814 if (parm_table[*i].p_class == P_LOCAL &&
7815 parm_table[*i].ptr &&
7816 (*parm_table[*i].label != '-') &&
7817 ((*i) == 0 ||
7818 (parm_table[*i].ptr !=
7819 parm_table[(*i) - 1].ptr)))
7820 {
7821 int pdiff =
7822 PTR_DIFF(parm_table[*i].ptr,
7823 &sDefault);
7824
7825 if (allparameters ||
7826 !equal_parameter(parm_table[*i].type,
7827 ((char *)pService) +
7828 pdiff,
7829 ((char *)&sDefault) +
7830 pdiff))
7831 {
7832 return &parm_table[(*i)++];
7833 }
7834 }
7835 }
7836 }
7837
7838 return NULL;
7839}
7840
7841
7842#if 0
7843/***************************************************************************
7844 Display the contents of a single copy structure.
7845***************************************************************************/
7846static void dump_copy_map(bool *pcopymap)
7847{
7848 int i;
7849 if (!pcopymap)
7850 return;
7851
7852 printf("\n\tNon-Copied parameters:\n");
7853
7854 for (i = 0; parm_table[i].label; i++)
7855 if (parm_table[i].p_class == P_LOCAL &&
7856 parm_table[i].ptr && !pcopymap[i] &&
7857 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
7858 {
7859 printf("\t\t%s\n", parm_table[i].label);
7860 }
7861}
7862#endif
7863
7864/***************************************************************************
7865 Return TRUE if the passed service number is within range.
7866***************************************************************************/
7867
7868bool lp_snum_ok(int iService)
7869{
7870 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
7871}
7872
7873/***************************************************************************
7874 Auto-load some home services.
7875***************************************************************************/
7876
7877static void lp_add_auto_services(char *str)
7878{
7879 char *s;
7880 char *p;
7881 int homes;
7882 char *saveptr;
7883
7884 if (!str)
7885 return;
7886
7887 s = SMB_STRDUP(str);
7888 if (!s)
7889 return;
7890
7891 homes = lp_servicenumber(HOMES_NAME);
7892
7893 for (p = strtok_r(s, LIST_SEP, &saveptr); p;
7894 p = strtok_r(NULL, LIST_SEP, &saveptr)) {
7895 char *home;
7896
7897 if (lp_servicenumber(p) >= 0)
7898 continue;
7899
7900 home = get_user_home_dir(talloc_tos(), p);
7901
7902 if (home && home[0] && homes >= 0)
7903 lp_add_home(p, homes, p, home);
7904
7905 TALLOC_FREE(home);
7906 }
7907 SAFE_FREE(s);
7908}
7909
7910/***************************************************************************
7911 Auto-load one printer.
7912***************************************************************************/
7913
7914void lp_add_one_printer(const char *name, const char *comment, void *pdata)
7915{
7916 int printers = lp_servicenumber(PRINTERS_NAME);
7917 int i;
7918
7919 if (lp_servicenumber(name) < 0) {
7920 lp_add_printer(name, printers);
7921 if ((i = lp_servicenumber(name)) >= 0) {
7922 string_set(&ServicePtrs[i]->comment, comment);
7923 ServicePtrs[i]->autoloaded = True;
7924 }
7925 }
7926}
7927
7928/***************************************************************************
7929 Have we loaded a services file yet?
7930***************************************************************************/
7931
7932bool lp_loaded(void)
7933{
7934 return (bLoaded);
7935}
7936
7937/***************************************************************************
7938 Unload unused services.
7939***************************************************************************/
7940
7941void lp_killunused(bool (*snumused) (int))
7942{
7943 int i;
7944 for (i = 0; i < iNumServices; i++) {
7945 if (!VALID(i))
7946 continue;
7947
7948 /* don't kill autoloaded or usershare services */
7949 if ( ServicePtrs[i]->autoloaded ||
7950 ServicePtrs[i]->usershare == USERSHARE_VALID) {
7951 continue;
7952 }
7953
7954 if (!snumused || !snumused(i)) {
7955 free_service_byindex(i);
7956 }
7957 }
7958}
7959
7960/**
7961 * Kill all except autoloaded and usershare services - convenience wrapper
7962 */
7963void lp_kill_all_services(void)
7964{
7965 lp_killunused(NULL);
7966}
7967
7968/***************************************************************************
7969 Unload a service.
7970***************************************************************************/
7971
7972void lp_killservice(int iServiceIn)
7973{
7974 if (VALID(iServiceIn)) {
7975 free_service_byindex(iServiceIn);
7976 }
7977}
7978
7979/***************************************************************************
7980 Save the curent values of all global and sDefault parameters into the
7981 defaults union. This allows swat and testparm to show only the
7982 changed (ie. non-default) parameters.
7983***************************************************************************/
7984
7985static void lp_save_defaults(void)
7986{
7987 int i;
7988 for (i = 0; parm_table[i].label; i++) {
7989 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
7990 continue;
7991 switch (parm_table[i].type) {
7992 case P_LIST:
7993 str_list_copy(
7994 NULL, &(parm_table[i].def.lvalue),
7995 *(const char ***)parm_table[i].ptr);
7996 break;
7997 case P_STRING:
7998 case P_USTRING:
7999 if (parm_table[i].ptr) {
8000 parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
8001 } else {
8002 parm_table[i].def.svalue = NULL;
8003 }
8004 break;
8005 case P_BOOL:
8006 case P_BOOLREV:
8007 parm_table[i].def.bvalue =
8008 *(bool *)parm_table[i].ptr;
8009 break;
8010 case P_CHAR:
8011 parm_table[i].def.cvalue =
8012 *(char *)parm_table[i].ptr;
8013 break;
8014 case P_INTEGER:
8015 case P_OCTAL:
8016 case P_ENUM:
8017 parm_table[i].def.ivalue =
8018 *(int *)parm_table[i].ptr;
8019 break;
8020 case P_SEP:
8021 break;
8022 }
8023 }
8024 defaults_saved = True;
8025}
8026
8027/*******************************************************************
8028 Set the server type we will announce as via nmbd.
8029********************************************************************/
8030
8031static const struct srv_role_tab {
8032 uint32 role;
8033 const char *role_str;
8034} srv_role_tab [] = {
8035 { ROLE_STANDALONE, "ROLE_STANDALONE" },
8036 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
8037 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
8038 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
8039 { 0, NULL }
8040};
8041
8042const char* server_role_str(uint32 role)
8043{
8044 int i = 0;
8045 for (i=0; srv_role_tab[i].role_str; i++) {
8046 if (role == srv_role_tab[i].role) {
8047 return srv_role_tab[i].role_str;
8048 }
8049 }
8050 return NULL;
8051}
8052
8053static void set_server_role(void)
8054{
8055 server_role = ROLE_STANDALONE;
8056
8057 switch (lp_security()) {
8058 case SEC_SHARE:
8059 if (lp_domain_logons())
8060 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
8061 break;
8062 case SEC_SERVER:
8063 if (lp_domain_logons())
8064 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
8065 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
8066 server_role = ROLE_STANDALONE;
8067 break;
8068 case SEC_DOMAIN:
8069 if (lp_domain_logons()) {
8070 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
8071 server_role = ROLE_DOMAIN_BDC;
8072 break;
8073 }
8074 server_role = ROLE_DOMAIN_MEMBER;
8075 break;
8076 case SEC_ADS:
8077 if (lp_domain_logons()) {
8078 server_role = ROLE_DOMAIN_PDC;
8079 break;
8080 }
8081 server_role = ROLE_DOMAIN_MEMBER;
8082 break;
8083 case SEC_USER:
8084 if (lp_domain_logons()) {
8085
8086 if (Globals.iDomainMaster) /* auto or yes */
8087 server_role = ROLE_DOMAIN_PDC;
8088 else
8089 server_role = ROLE_DOMAIN_BDC;
8090 }
8091 break;
8092 default:
8093 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
8094 break;
8095 }
8096
8097 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
8098}
8099
8100/***********************************************************
8101 If we should send plaintext/LANMAN passwords in the clinet
8102************************************************************/
8103
8104static void set_allowed_client_auth(void)
8105{
8106 if (Globals.bClientNTLMv2Auth) {
8107 Globals.bClientLanManAuth = False;
8108 }
8109 if (!Globals.bClientLanManAuth) {
8110 Globals.bClientPlaintextAuth = False;
8111 }
8112}
8113
8114/***************************************************************************
8115 JRA.
8116 The following code allows smbd to read a user defined share file.
8117 Yes, this is my intent. Yes, I'm comfortable with that...
8118
8119 THE FOLLOWING IS SECURITY CRITICAL CODE.
8120
8121 It washes your clothes, it cleans your house, it guards you while you sleep...
8122 Do not f%^k with it....
8123***************************************************************************/
8124
8125#define MAX_USERSHARE_FILE_SIZE (10*1024)
8126
8127/***************************************************************************
8128 Check allowed stat state of a usershare file.
8129 Ensure we print out who is dicking with us so the admin can
8130 get their sorry ass fired.
8131***************************************************************************/
8132
8133static bool check_usershare_stat(const char *fname, SMB_STRUCT_STAT *psbuf)
8134{
8135 if (!S_ISREG(psbuf->st_mode)) {
8136 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8137 "not a regular file\n",
8138 fname, (unsigned int)psbuf->st_uid ));
8139 return False;
8140 }
8141
8142 /* Ensure this doesn't have the other write bit set. */
8143 if (psbuf->st_mode & S_IWOTH) {
8144 DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
8145 "public write. Refusing to allow as a usershare file.\n",
8146 fname, (unsigned int)psbuf->st_uid ));
8147 return False;
8148 }
8149
8150 /* Should be 10k or less. */
8151 if (psbuf->st_size > MAX_USERSHARE_FILE_SIZE) {
8152 DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
8153 "too large (%u) to be a user share file.\n",
8154 fname, (unsigned int)psbuf->st_uid,
8155 (unsigned int)psbuf->st_size ));
8156 return False;
8157 }
8158
8159 return True;
8160}
8161
8162/***************************************************************************
8163 Parse the contents of a usershare file.
8164***************************************************************************/
8165
8166enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
8167 SMB_STRUCT_STAT *psbuf,
8168 const char *servicename,
8169 int snum,
8170 char **lines,
8171 int numlines,
8172 char **pp_sharepath,
8173 char **pp_comment,
8174 SEC_DESC **ppsd,
8175 bool *pallow_guest)
8176{
8177 const char **prefixallowlist = lp_usershare_prefix_allow_list();
8178 const char **prefixdenylist = lp_usershare_prefix_deny_list();
8179 int us_vers;
8180 SMB_STRUCT_DIR *dp;
8181 SMB_STRUCT_STAT sbuf;
8182 char *sharepath = NULL;
8183 char *comment = NULL;
8184
8185 *pp_sharepath = NULL;
8186 *pp_comment = NULL;
8187
8188 *pallow_guest = False;
8189
8190 if (numlines < 4) {
8191 return USERSHARE_MALFORMED_FILE;
8192 }
8193
8194 if (strcmp(lines[0], "#VERSION 1") == 0) {
8195 us_vers = 1;
8196 } else if (strcmp(lines[0], "#VERSION 2") == 0) {
8197 us_vers = 2;
8198 if (numlines < 5) {
8199 return USERSHARE_MALFORMED_FILE;
8200 }
8201 } else {
8202 return USERSHARE_BAD_VERSION;
8203 }
8204
8205 if (strncmp(lines[1], "path=", 5) != 0) {
8206 return USERSHARE_MALFORMED_PATH;
8207 }
8208
8209 sharepath = talloc_strdup(ctx, &lines[1][5]);
8210 if (!sharepath) {
8211 return USERSHARE_POSIX_ERR;
8212 }
8213 trim_string(sharepath, " ", " ");
8214
8215 if (strncmp(lines[2], "comment=", 8) != 0) {
8216 return USERSHARE_MALFORMED_COMMENT_DEF;
8217 }
8218
8219 comment = talloc_strdup(ctx, &lines[2][8]);
8220 if (!comment) {
8221 return USERSHARE_POSIX_ERR;
8222 }
8223 trim_string(comment, " ", " ");
8224 trim_char(comment, '"', '"');
8225
8226 if (strncmp(lines[3], "usershare_acl=", 14) != 0) {
8227 return USERSHARE_MALFORMED_ACL_DEF;
8228 }
8229
8230 if (!parse_usershare_acl(ctx, &lines[3][14], ppsd)) {
8231 return USERSHARE_ACL_ERR;
8232 }
8233
8234 if (us_vers == 2) {
8235 if (strncmp(lines[4], "guest_ok=", 9) != 0) {
8236 return USERSHARE_MALFORMED_ACL_DEF;
8237 }
8238 if (lines[4][9] == 'y') {
8239 *pallow_guest = True;
8240 }
8241 }
8242
8243 if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
8244 /* Path didn't change, no checks needed. */
8245 *pp_sharepath = sharepath;
8246 *pp_comment = comment;
8247 return USERSHARE_OK;
8248 }
8249
8250 /* The path *must* be absolute. */
8251 if (sharepath[0] != '/') {
8252 DEBUG(2,("parse_usershare_file: share %s: path %s is not an absolute path.\n",
8253 servicename, sharepath));
8254 return USERSHARE_PATH_NOT_ABSOLUTE;
8255 }
8256
8257 /* If there is a usershare prefix deny list ensure one of these paths
8258 doesn't match the start of the user given path. */
8259 if (prefixdenylist) {
8260 int i;
8261 for ( i=0; prefixdenylist[i]; i++ ) {
8262 DEBUG(10,("parse_usershare_file: share %s : checking prefixdenylist[%d]='%s' against %s\n",
8263 servicename, i, prefixdenylist[i], sharepath ));
8264 if (memcmp( sharepath, prefixdenylist[i], strlen(prefixdenylist[i])) == 0) {
8265 DEBUG(2,("parse_usershare_file: share %s path %s starts with one of the "
8266 "usershare prefix deny list entries.\n",
8267 servicename, sharepath));
8268 return USERSHARE_PATH_IS_DENIED;
8269 }
8270 }
8271 }
8272
8273 /* If there is a usershare prefix allow list ensure one of these paths
8274 does match the start of the user given path. */
8275
8276 if (prefixallowlist) {
8277 int i;
8278 for ( i=0; prefixallowlist[i]; i++ ) {
8279 DEBUG(10,("parse_usershare_file: share %s checking prefixallowlist[%d]='%s' against %s\n",
8280 servicename, i, prefixallowlist[i], sharepath ));
8281 if (memcmp( sharepath, prefixallowlist[i], strlen(prefixallowlist[i])) == 0) {
8282 break;
8283 }
8284 }
8285 if (prefixallowlist[i] == NULL) {
8286 DEBUG(2,("parse_usershare_file: share %s path %s doesn't start with one of the "
8287 "usershare prefix allow list entries.\n",
8288 servicename, sharepath));
8289 return USERSHARE_PATH_NOT_ALLOWED;
8290 }
8291 }
8292
8293 /* Ensure this is pointing to a directory. */
8294 dp = sys_opendir(sharepath);
8295
8296 if (!dp) {
8297 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8298 servicename, sharepath));
8299 return USERSHARE_PATH_NOT_DIRECTORY;
8300 }
8301
8302 /* Ensure the owner of the usershare file has permission to share
8303 this directory. */
8304
8305 if (sys_stat(sharepath, &sbuf) == -1) {
8306 DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
8307 servicename, sharepath, strerror(errno) ));
8308 sys_closedir(dp);
8309 return USERSHARE_POSIX_ERR;
8310 }
8311
8312 sys_closedir(dp);
8313
8314 if (!S_ISDIR(sbuf.st_mode)) {
8315 DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
8316 servicename, sharepath ));
8317 return USERSHARE_PATH_NOT_DIRECTORY;
8318 }
8319
8320 /* Check if sharing is restricted to owner-only. */
8321 /* psbuf is the stat of the usershare definition file,
8322 sbuf is the stat of the target directory to be shared. */
8323
8324 if (lp_usershare_owner_only()) {
8325 /* root can share anything. */
8326 if ((psbuf->st_uid != 0) && (sbuf.st_uid != psbuf->st_uid)) {
8327 return USERSHARE_PATH_NOT_ALLOWED;
8328 }
8329 }
8330
8331 *pp_sharepath = sharepath;
8332 *pp_comment = comment;
8333 return USERSHARE_OK;
8334}
8335
8336/***************************************************************************
8337 Deal with a usershare file.
8338 Returns:
8339 >= 0 - snum
8340 -1 - Bad name, invalid contents.
8341 - service name already existed and not a usershare, problem
8342 with permissions to share directory etc.
8343***************************************************************************/
8344
8345static int process_usershare_file(const char *dir_name, const char *file_name, int snum_template)
8346{
8347 SMB_STRUCT_STAT sbuf;
8348 SMB_STRUCT_STAT lsbuf;
8349 char *fname = NULL;
8350 char *sharepath = NULL;
8351 char *comment = NULL;
8352 fstring service_name;
8353 char **lines = NULL;
8354 int numlines = 0;
8355 int fd = -1;
8356 int iService = -1;
8357 TALLOC_CTX *ctx = NULL;
8358 SEC_DESC *psd = NULL;
8359 bool guest_ok = False;
8360
8361 /* Ensure share name doesn't contain invalid characters. */
8362 if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
8363 DEBUG(0,("process_usershare_file: share name %s contains "
8364 "invalid characters (any of %s)\n",
8365 file_name, INVALID_SHARENAME_CHARS ));
8366 return -1;
8367 }
8368
8369 fstrcpy(service_name, file_name);
8370
8371 if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
8372 }
8373
8374 /* Minimize the race condition by doing an lstat before we
8375 open and fstat. Ensure this isn't a symlink link. */
8376
8377 if (sys_lstat(fname, &lsbuf) != 0) {
8378 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
8379 fname, strerror(errno) ));
8380 SAFE_FREE(fname);
8381 return -1;
8382 }
8383
8384 /* This must be a regular file, not a symlink, directory or
8385 other strange filetype. */
8386 if (!check_usershare_stat(fname, &lsbuf)) {
8387 SAFE_FREE(fname);
8388 return -1;
8389 }
8390
8391 {
8392 char *canon_name = canonicalize_servicename(service_name);
8393 TDB_DATA data = dbwrap_fetch_bystring(
8394 ServiceHash, canon_name, canon_name);
8395
8396 iService = -1;
8397
8398 if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
8399 iService = *(int *)data.dptr;
8400 }
8401 TALLOC_FREE(canon_name);
8402 }
8403
8404 if (iService != -1 && ServicePtrs[iService]->usershare_last_mod == lsbuf.st_mtime) {
8405 /* Nothing changed - Mark valid and return. */
8406 DEBUG(10,("process_usershare_file: service %s not changed.\n",
8407 service_name ));
8408 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8409 SAFE_FREE(fname);
8410 return iService;
8411 }
8412
8413 /* Try and open the file read only - no symlinks allowed. */
8414#ifdef O_NOFOLLOW
8415 fd = sys_open(fname, O_RDONLY|O_NOFOLLOW, 0);
8416#else
8417 fd = sys_open(fname, O_RDONLY, 0);
8418#endif
8419
8420 if (fd == -1) {
8421 DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
8422 fname, strerror(errno) ));
8423 SAFE_FREE(fname);
8424 return -1;
8425 }
8426
8427 /* Now fstat to be *SURE* it's a regular file. */
8428 if (sys_fstat(fd, &sbuf) != 0) {
8429 close(fd);
8430 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
8431 fname, strerror(errno) ));
8432 SAFE_FREE(fname);
8433 return -1;
8434 }
8435
8436 /* Is it the same dev/inode as was lstated ? */
8437 if (lsbuf.st_dev != sbuf.st_dev || lsbuf.st_ino != sbuf.st_ino) {
8438 close(fd);
8439 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
8440 "Symlink spoofing going on ?\n", fname ));
8441 SAFE_FREE(fname);
8442 return -1;
8443 }
8444
8445 /* This must be a regular file, not a symlink, directory or
8446 other strange filetype. */
8447 if (!check_usershare_stat(fname, &sbuf)) {
8448 SAFE_FREE(fname);
8449 return -1;
8450 }
8451
8452 lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE);
8453
8454 close(fd);
8455 if (lines == NULL) {
8456 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
8457 fname, (unsigned int)sbuf.st_uid ));
8458 SAFE_FREE(fname);
8459 return -1;
8460 }
8461
8462 SAFE_FREE(fname);
8463
8464 /* Should we allow printers to be shared... ? */
8465 ctx = talloc_init("usershare_sd_xctx");
8466 if (!ctx) {
8467 file_lines_free(lines);
8468 return 1;
8469 }
8470
8471 if (parse_usershare_file(ctx, &sbuf, service_name,
8472 iService, lines, numlines, &sharepath,
8473 &comment, &psd, &guest_ok) != USERSHARE_OK) {
8474 talloc_destroy(ctx);
8475 file_lines_free(lines);
8476 return -1;
8477 }
8478
8479 file_lines_free(lines);
8480
8481 /* Everything ok - add the service possibly using a template. */
8482 if (iService < 0) {
8483 const struct service *sp = &sDefault;
8484 if (snum_template != -1) {
8485 sp = ServicePtrs[snum_template];
8486 }
8487
8488 if ((iService = add_a_service(sp, service_name)) < 0) {
8489 DEBUG(0, ("process_usershare_file: Failed to add "
8490 "new service %s\n", service_name));
8491 talloc_destroy(ctx);
8492 return -1;
8493 }
8494
8495 /* Read only is controlled by usershare ACL below. */
8496 ServicePtrs[iService]->bRead_only = False;
8497 }
8498
8499 /* Write the ACL of the new/modified share. */
8500 if (!set_share_security(service_name, psd)) {
8501 DEBUG(0, ("process_usershare_file: Failed to set share "
8502 "security for user share %s\n",
8503 service_name ));
8504 lp_remove_service(iService);
8505 talloc_destroy(ctx);
8506 return -1;
8507 }
8508
8509 /* If from a template it may be marked invalid. */
8510 ServicePtrs[iService]->valid = True;
8511
8512 /* Set the service as a valid usershare. */
8513 ServicePtrs[iService]->usershare = USERSHARE_VALID;
8514
8515 /* Set guest access. */
8516 if (lp_usershare_allow_guests()) {
8517 ServicePtrs[iService]->bGuest_ok = guest_ok;
8518 }
8519
8520 /* And note when it was loaded. */
8521 ServicePtrs[iService]->usershare_last_mod = sbuf.st_mtime;
8522 string_set(&ServicePtrs[iService]->szPath, sharepath);
8523 string_set(&ServicePtrs[iService]->comment, comment);
8524
8525 talloc_destroy(ctx);
8526
8527 return iService;
8528}
8529
8530/***************************************************************************
8531 Checks if a usershare entry has been modified since last load.
8532***************************************************************************/
8533
8534static bool usershare_exists(int iService, time_t *last_mod)
8535{
8536 SMB_STRUCT_STAT lsbuf;
8537 const char *usersharepath = Globals.szUsersharePath;
8538 char *fname;
8539
8540 if (asprintf(&fname, "%s/%s",
8541 usersharepath,
8542 ServicePtrs[iService]->szService) < 0) {
8543 return false;
8544 }
8545
8546 if (sys_lstat(fname, &lsbuf) != 0) {
8547 SAFE_FREE(fname);
8548 return false;
8549 }
8550
8551 if (!S_ISREG(lsbuf.st_mode)) {
8552 SAFE_FREE(fname);
8553 return false;
8554 }
8555
8556 SAFE_FREE(fname);
8557 *last_mod = lsbuf.st_mtime;
8558 return true;
8559}
8560
8561/***************************************************************************
8562 Load a usershare service by name. Returns a valid servicenumber or -1.
8563***************************************************************************/
8564
8565int load_usershare_service(const char *servicename)
8566{
8567 SMB_STRUCT_STAT sbuf;
8568 const char *usersharepath = Globals.szUsersharePath;
8569 int max_user_shares = Globals.iUsershareMaxShares;
8570 int snum_template = -1;
8571
8572 if (*usersharepath == 0 || max_user_shares == 0) {
8573 return -1;
8574 }
8575
8576 if (sys_stat(usersharepath, &sbuf) != 0) {
8577 DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
8578 usersharepath, strerror(errno) ));
8579 return -1;
8580 }
8581
8582 if (!S_ISDIR(sbuf.st_mode)) {
8583 DEBUG(0,("load_usershare_service: %s is not a directory.\n",
8584 usersharepath ));
8585 return -1;
8586 }
8587
8588 /*
8589 * This directory must be owned by root, and have the 't' bit set.
8590 * It also must not be writable by "other".
8591 */
8592
8593#ifdef S_ISVTX
8594 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8595#else
8596 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8597#endif
8598 DEBUG(0,("load_usershare_service: directory %s is not owned by root "
8599 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8600 usersharepath ));
8601 return -1;
8602 }
8603
8604 /* Ensure the template share exists if it's set. */
8605 if (Globals.szUsershareTemplateShare[0]) {
8606 /* We can't use lp_servicenumber here as we are recommending that
8607 template shares have -valid=False set. */
8608 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8609 if (ServicePtrs[snum_template]->szService &&
8610 strequal(ServicePtrs[snum_template]->szService,
8611 Globals.szUsershareTemplateShare)) {
8612 break;
8613 }
8614 }
8615
8616 if (snum_template == -1) {
8617 DEBUG(0,("load_usershare_service: usershare template share %s "
8618 "does not exist.\n",
8619 Globals.szUsershareTemplateShare ));
8620 return -1;
8621 }
8622 }
8623
8624 return process_usershare_file(usersharepath, servicename, snum_template);
8625}
8626
8627/***************************************************************************
8628 Load all user defined shares from the user share directory.
8629 We only do this if we're enumerating the share list.
8630 This is the function that can delete usershares that have
8631 been removed.
8632***************************************************************************/
8633
8634int load_usershare_shares(void)
8635{
8636 SMB_STRUCT_DIR *dp;
8637 SMB_STRUCT_STAT sbuf;
8638 SMB_STRUCT_DIRENT *de;
8639 int num_usershares = 0;
8640 int max_user_shares = Globals.iUsershareMaxShares;
8641 unsigned int num_dir_entries, num_bad_dir_entries, num_tmp_dir_entries;
8642 unsigned int allowed_bad_entries = ((2*max_user_shares)/10);
8643 unsigned int allowed_tmp_entries = ((2*max_user_shares)/10);
8644 int iService;
8645 int snum_template = -1;
8646 const char *usersharepath = Globals.szUsersharePath;
8647 int ret = lp_numservices();
8648
8649 if (max_user_shares == 0 || *usersharepath == '\0') {
8650 return lp_numservices();
8651 }
8652
8653 if (sys_stat(usersharepath, &sbuf) != 0) {
8654 DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
8655 usersharepath, strerror(errno) ));
8656 return ret;
8657 }
8658
8659 /*
8660 * This directory must be owned by root, and have the 't' bit set.
8661 * It also must not be writable by "other".
8662 */
8663
8664#ifdef S_ISVTX
8665 if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
8666#else
8667 if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
8668#endif
8669 DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
8670 "or does not have the sticky bit 't' set or is writable by anyone.\n",
8671 usersharepath ));
8672 return ret;
8673 }
8674
8675 /* Ensure the template share exists if it's set. */
8676 if (Globals.szUsershareTemplateShare[0]) {
8677 /* We can't use lp_servicenumber here as we are recommending that
8678 template shares have -valid=False set. */
8679 for (snum_template = iNumServices - 1; snum_template >= 0; snum_template--) {
8680 if (ServicePtrs[snum_template]->szService &&
8681 strequal(ServicePtrs[snum_template]->szService,
8682 Globals.szUsershareTemplateShare)) {
8683 break;
8684 }
8685 }
8686
8687 if (snum_template == -1) {
8688 DEBUG(0,("load_usershare_shares: usershare template share %s "
8689 "does not exist.\n",
8690 Globals.szUsershareTemplateShare ));
8691 return ret;
8692 }
8693 }
8694
8695 /* Mark all existing usershares as pending delete. */
8696 for (iService = iNumServices - 1; iService >= 0; iService--) {
8697 if (VALID(iService) && ServicePtrs[iService]->usershare) {
8698 ServicePtrs[iService]->usershare = USERSHARE_PENDING_DELETE;
8699 }
8700 }
8701
8702 dp = sys_opendir(usersharepath);
8703 if (!dp) {
8704 DEBUG(0,("load_usershare_shares:: failed to open directory %s. %s\n",
8705 usersharepath, strerror(errno) ));
8706 return ret;
8707 }
8708
8709 for (num_dir_entries = 0, num_bad_dir_entries = 0, num_tmp_dir_entries = 0;
8710 (de = sys_readdir(dp));
8711 num_dir_entries++ ) {
8712 int r;
8713 const char *n = de->d_name;
8714
8715 /* Ignore . and .. */
8716 if (*n == '.') {
8717 if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
8718 continue;
8719 }
8720 }
8721
8722 if (n[0] == ':') {
8723 /* Temporary file used when creating a share. */
8724 num_tmp_dir_entries++;
8725 }
8726
8727 /* Allow 20% tmp entries. */
8728 if (num_tmp_dir_entries > allowed_tmp_entries) {
8729 DEBUG(0,("load_usershare_shares: too many temp entries (%u) "
8730 "in directory %s\n",
8731 num_tmp_dir_entries, usersharepath));
8732 break;
8733 }
8734
8735 r = process_usershare_file(usersharepath, n, snum_template);
8736 if (r == 0) {
8737 /* Update the services count. */
8738 num_usershares++;
8739 if (num_usershares >= max_user_shares) {
8740 DEBUG(0,("load_usershare_shares: max user shares reached "
8741 "on file %s in directory %s\n",
8742 n, usersharepath ));
8743 break;
8744 }
8745 } else if (r == -1) {
8746 num_bad_dir_entries++;
8747 }
8748
8749 /* Allow 20% bad entries. */
8750 if (num_bad_dir_entries > allowed_bad_entries) {
8751 DEBUG(0,("load_usershare_shares: too many bad entries (%u) "
8752 "in directory %s\n",
8753 num_bad_dir_entries, usersharepath));
8754 break;
8755 }
8756
8757 /* Allow 20% bad entries. */
8758 if (num_dir_entries > max_user_shares + allowed_bad_entries) {
8759 DEBUG(0,("load_usershare_shares: too many total entries (%u) "
8760 "in directory %s\n",
8761 num_dir_entries, usersharepath));
8762 break;
8763 }
8764 }
8765
8766 sys_closedir(dp);
8767
8768 /* Sweep through and delete any non-refreshed usershares that are
8769 not currently in use. */
8770 for (iService = iNumServices - 1; iService >= 0; iService--) {
8771 if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
8772 if (conn_snum_used(iService)) {
8773 continue;
8774 }
8775 /* Remove from the share ACL db. */
8776 DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
8777 lp_servicename(iService) ));
8778 delete_share_security(lp_servicename(iService));
8779 free_service_byindex(iService);
8780 }
8781 }
8782
8783 return lp_numservices();
8784}
8785
8786/********************************************************
8787 Destroy global resources allocated in this file
8788********************************************************/
8789
8790void gfree_loadparm(void)
8791{
8792 struct file_lists *f;
8793 struct file_lists *next;
8794 int i;
8795
8796 /* Free the file lists */
8797
8798 f = file_lists;
8799 while( f ) {
8800 next = f->next;
8801 SAFE_FREE( f->name );
8802 SAFE_FREE( f->subfname );
8803 SAFE_FREE( f );
8804 f = next;
8805 }
8806 file_lists = NULL;
8807
8808 /* Free resources allocated to services */
8809
8810 for ( i = 0; i < iNumServices; i++ ) {
8811 if ( VALID(i) ) {
8812 free_service_byindex(i);
8813 }
8814 }
8815
8816 SAFE_FREE( ServicePtrs );
8817 iNumServices = 0;
8818
8819 /* Now release all resources allocated to global
8820 parameters and the default service */
8821
8822 for (i = 0; parm_table[i].label; i++)
8823 {
8824 if ( parm_table[i].type == P_STRING
8825 || parm_table[i].type == P_USTRING )
8826 {
8827 string_free( (char**)parm_table[i].ptr );
8828 }
8829 else if (parm_table[i].type == P_LIST) {
8830 TALLOC_FREE( *((char***)parm_table[i].ptr) );
8831 }
8832 }
8833}
8834
8835
8836/***************************************************************************
8837 Allow client apps to specify that they are a client
8838***************************************************************************/
8839void lp_set_in_client(bool b)
8840{
8841 in_client = b;
8842}
8843
8844
8845/***************************************************************************
8846 Determine if we're running in a client app
8847***************************************************************************/
8848bool lp_is_in_client(void)
8849{
8850 return in_client;
8851}
8852
8853
8854
8855
8856/***************************************************************************
8857 Load the services array from the services file. Return True on success,
8858 False on failure.
8859***************************************************************************/
8860
8861bool lp_load_ex(const char *pszFname,
8862 bool global_only,
8863 bool save_defaults,
8864 bool add_ipc,
8865 bool initialize_globals,
8866 bool allow_include_registry,
8867 bool allow_registry_shares)
8868{
8869 char *n2 = NULL;
8870 bool bRetval;
8871 struct param_opt_struct *data, *pdata;
8872
8873 bRetval = False;
8874
8875 DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
8876
8877 bInGlobalSection = True;
8878 bGlobalOnly = global_only;
8879 bAllowIncludeRegistry = allow_include_registry;
8880
8881 init_globals(! initialize_globals);
8882 debug_init();
8883
8884 if (save_defaults) {
8885 init_locals();
8886 lp_save_defaults();
8887 }
8888
8889 /* We get sections first, so have to start 'behind' to make up */
8890 iServiceIndex = -1;
8891
8892 if (Globals.param_opt != NULL) {
8893 data = Globals.param_opt;
8894 while (data) {
8895 string_free(&data->key);
8896 string_free(&data->value);
8897 TALLOC_FREE(data->list);
8898 pdata = data->next;
8899 SAFE_FREE(data);
8900 data = pdata;
8901 }
8902 Globals.param_opt = NULL;
8903 }
8904
8905 if (lp_config_backend_is_file()) {
8906 n2 = alloc_sub_basic(get_current_username(),
8907 current_user_info.domain,
8908 pszFname);
8909 if (!n2) {
8910 smb_panic("lp_load_ex: out of memory");
8911 }
8912
8913 add_to_file_list(pszFname, n2);
8914
8915 bRetval = pm_process(n2, do_section, do_parameter, NULL);
8916 SAFE_FREE(n2);
8917
8918 /* finish up the last section */
8919 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
8920 if (bRetval) {
8921 if (iServiceIndex >= 0) {
8922 bRetval = service_ok(iServiceIndex);
8923 }
8924 }
8925
8926 if (lp_config_backend_is_registry()) {
8927 /* config backend changed to registry in config file */
8928 /*
8929 * We need to use this extra global variable here to
8930 * survive restart: init_globals uses this as a default
8931 * for ConfigBackend. Otherwise, init_globals would
8932 * send us into an endless loop here.
8933 */
8934 config_backend = CONFIG_BACKEND_REGISTRY;
8935 /* start over */
8936 DEBUG(1, ("lp_load_ex: changing to config backend "
8937 "registry\n"));
8938 init_globals(false);
8939 lp_kill_all_services();
8940 return lp_load_ex(pszFname, global_only, save_defaults,
8941 add_ipc, initialize_globals,
8942 allow_include_registry,
8943 allow_registry_shares);
8944 }
8945 } else if (lp_config_backend_is_registry()) {
8946 bRetval = process_registry_globals();
8947 } else {
8948 DEBUG(0, ("Illegal config backend given: %d\n",
8949 lp_config_backend()));
8950 bRetval = false;
8951 }
8952
8953 if (bRetval && lp_registry_shares() && allow_registry_shares) {
8954 bRetval = process_registry_shares();
8955 }
8956
8957 lp_add_auto_services(lp_auto_services());
8958
8959 if (add_ipc) {
8960 /* When 'restrict anonymous = 2' guest connections to ipc$
8961 are denied */
8962 lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
8963 if ( lp_enable_asu_support() ) {
8964 lp_add_ipc("ADMIN$", false);
8965 }
8966 }
8967
8968 set_server_role();
8969 set_default_server_announce_type();
8970 set_allowed_client_auth();
8971
8972 bLoaded = True;
8973
8974 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
8975 /* if bWINSsupport is true and we are in the client */
8976 if (lp_is_in_client() && Globals.bWINSsupport) {
8977 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
8978 }
8979
8980 init_iconv();
8981
8982 bAllowIncludeRegistry = true;
8983
8984 return (bRetval);
8985}
8986
8987bool lp_load(const char *pszFname,
8988 bool global_only,
8989 bool save_defaults,
8990 bool add_ipc,
8991 bool initialize_globals)
8992{
8993 return lp_load_ex(pszFname,
8994 global_only,
8995 save_defaults,
8996 add_ipc,
8997 initialize_globals,
8998 true, false);
8999}
9000
9001bool lp_load_initial_only(const char *pszFname)
9002{
9003 return lp_load_ex(pszFname,
9004 true,
9005 false,
9006 false,
9007 true,
9008 false,
9009 false);
9010}
9011
9012bool lp_load_with_registry_shares(const char *pszFname,
9013 bool global_only,
9014 bool save_defaults,
9015 bool add_ipc,
9016 bool initialize_globals)
9017{
9018 return lp_load_ex(pszFname,
9019 global_only,
9020 save_defaults,
9021 add_ipc,
9022 initialize_globals,
9023 true,
9024 true);
9025}
9026
9027/***************************************************************************
9028 Return the max number of services.
9029***************************************************************************/
9030
9031int lp_numservices(void)
9032{
9033 return (iNumServices);
9034}
9035
9036/***************************************************************************
9037Display the contents of the services array in human-readable form.
9038***************************************************************************/
9039
9040void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9041{
9042 int iService;
9043
9044 if (show_defaults)
9045 defaults_saved = False;
9046
9047 dump_globals(f);
9048
9049 dump_a_service(&sDefault, f);
9050
9051 for (iService = 0; iService < maxtoprint; iService++) {
9052 fprintf(f,"\n");
9053 lp_dump_one(f, show_defaults, iService);
9054 }
9055}
9056
9057/***************************************************************************
9058Display the contents of one service in human-readable form.
9059***************************************************************************/
9060
9061void lp_dump_one(FILE * f, bool show_defaults, int snum)
9062{
9063 if (VALID(snum)) {
9064 if (ServicePtrs[snum]->szService[0] == '\0')
9065 return;
9066 dump_a_service(ServicePtrs[snum], f);
9067 }
9068}
9069
9070/***************************************************************************
9071Return the number of the service with the given name, or -1 if it doesn't
9072exist. Note that this is a DIFFERENT ANIMAL from the internal function
9073getservicebyname()! This works ONLY if all services have been loaded, and
9074does not copy the found service.
9075***************************************************************************/
9076
9077int lp_servicenumber(const char *pszServiceName)
9078{
9079 int iService;
9080 fstring serviceName;
9081
9082 if (!pszServiceName) {
9083 return GLOBAL_SECTION_SNUM;
9084 }
9085
9086 for (iService = iNumServices - 1; iService >= 0; iService--) {
9087 if (VALID(iService) && ServicePtrs[iService]->szService) {
9088 /*
9089 * The substitution here is used to support %U is
9090 * service names
9091 */
9092 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9093 standard_sub_basic(get_current_username(),
9094 current_user_info.domain,
9095 serviceName,sizeof(serviceName));
9096 if (strequal(serviceName, pszServiceName)) {
9097 break;
9098 }
9099 }
9100 }
9101
9102 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9103 time_t last_mod;
9104
9105 if (!usershare_exists(iService, &last_mod)) {
9106 /* Remove the share security tdb entry for it. */
9107 delete_share_security(lp_servicename(iService));
9108 /* Remove it from the array. */
9109 free_service_byindex(iService);
9110 /* Doesn't exist anymore. */
9111 return GLOBAL_SECTION_SNUM;
9112 }
9113
9114 /* Has it been modified ? If so delete and reload. */
9115 if (ServicePtrs[iService]->usershare_last_mod < last_mod) {
9116 /* Remove it from the array. */
9117 free_service_byindex(iService);
9118 /* and now reload it. */
9119 iService = load_usershare_service(pszServiceName);
9120 }
9121 }
9122
9123 if (iService < 0) {
9124 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9125 return GLOBAL_SECTION_SNUM;
9126 }
9127
9128 return (iService);
9129}
9130
9131bool share_defined(const char *service_name)
9132{
9133 return (lp_servicenumber(service_name) != -1);
9134}
9135
9136struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9137 const char *sharename)
9138{
9139 struct share_params *result;
9140 char *sname;
9141 int snum;
9142
9143 if (!(sname = SMB_STRDUP(sharename))) {
9144 return NULL;
9145 }
9146
9147 snum = find_service(sname);
9148 SAFE_FREE(sname);
9149
9150 if (snum < 0) {
9151 return NULL;
9152 }
9153
9154 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9155 DEBUG(0, ("talloc failed\n"));
9156 return NULL;
9157 }
9158
9159 result->service = snum;
9160 return result;
9161}
9162
9163struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9164{
9165 struct share_iterator *result;
9166
9167 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9168 DEBUG(0, ("talloc failed\n"));
9169 return NULL;
9170 }
9171
9172 result->next_id = 0;
9173 return result;
9174}
9175
9176struct share_params *next_share(struct share_iterator *list)
9177{
9178 struct share_params *result;
9179
9180 while (!lp_snum_ok(list->next_id) &&
9181 (list->next_id < lp_numservices())) {
9182 list->next_id += 1;
9183 }
9184
9185 if (list->next_id >= lp_numservices()) {
9186 return NULL;
9187 }
9188
9189 if (!(result = TALLOC_P(list, struct share_params))) {
9190 DEBUG(0, ("talloc failed\n"));
9191 return NULL;
9192 }
9193
9194 result->service = list->next_id;
9195 list->next_id += 1;
9196 return result;
9197}
9198
9199struct share_params *next_printer(struct share_iterator *list)
9200{
9201 struct share_params *result;
9202
9203 while ((result = next_share(list)) != NULL) {
9204 if (lp_print_ok(result->service)) {
9205 break;
9206 }
9207 }
9208 return result;
9209}
9210
9211/*
9212 * This is a hack for a transition period until we transformed all code from
9213 * service numbers to struct share_params.
9214 */
9215
9216struct share_params *snum2params_static(int snum)
9217{
9218 static struct share_params result;
9219 result.service = snum;
9220 return &result;
9221}
9222
9223/*******************************************************************
9224 A useful volume label function.
9225********************************************************************/
9226
9227const char *volume_label(int snum)
9228{
9229 char *ret;
9230 const char *label = lp_volume(snum);
9231 if (!*label) {
9232 label = lp_servicename(snum);
9233 }
9234
9235 /* This returns a 33 byte guarenteed null terminated string. */
9236 ret = talloc_strndup(talloc_tos(), label, 32);
9237 if (!ret) {
9238 return "";
9239 }
9240 return ret;
9241}
9242
9243/*******************************************************************
9244 Set the server type we will announce as via nmbd.
9245********************************************************************/
9246
9247static void set_default_server_announce_type(void)
9248{
9249 default_server_announce = 0;
9250 default_server_announce |= SV_TYPE_WORKSTATION;
9251 default_server_announce |= SV_TYPE_SERVER;
9252 default_server_announce |= SV_TYPE_SERVER_UNIX;
9253
9254 /* note that the flag should be set only if we have a
9255 printer service but nmbd doesn't actually load the
9256 services so we can't tell --jerry */
9257
9258 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9259
9260 switch (lp_announce_as()) {
9261 case ANNOUNCE_AS_NT_SERVER:
9262 default_server_announce |= SV_TYPE_SERVER_NT;
9263 /* fall through... */
9264 case ANNOUNCE_AS_NT_WORKSTATION:
9265 default_server_announce |= SV_TYPE_NT;
9266 break;
9267 case ANNOUNCE_AS_WIN95:
9268 default_server_announce |= SV_TYPE_WIN95_PLUS;
9269 break;
9270 case ANNOUNCE_AS_WFW:
9271 default_server_announce |= SV_TYPE_WFW;
9272 break;
9273 default:
9274 break;
9275 }
9276
9277 switch (lp_server_role()) {
9278 case ROLE_DOMAIN_MEMBER:
9279 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9280 break;
9281 case ROLE_DOMAIN_PDC:
9282 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9283 break;
9284 case ROLE_DOMAIN_BDC:
9285 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9286 break;
9287 case ROLE_STANDALONE:
9288 default:
9289 break;
9290 }
9291 if (lp_time_server())
9292 default_server_announce |= SV_TYPE_TIME_SOURCE;
9293
9294 if (lp_host_msdfs())
9295 default_server_announce |= SV_TYPE_DFS_SERVER;
9296}
9297
9298/***********************************************************
9299 returns role of Samba server
9300************************************************************/
9301
9302int lp_server_role(void)
9303{
9304 return server_role;
9305}
9306
9307/***********************************************************
9308 If we are PDC then prefer us as DMB
9309************************************************************/
9310
9311bool lp_domain_master(void)
9312{
9313 if (Globals.iDomainMaster == Auto)
9314 return (lp_server_role() == ROLE_DOMAIN_PDC);
9315
9316 return (bool)Globals.iDomainMaster;
9317}
9318
9319/***********************************************************
9320 If we are DMB then prefer us as LMB
9321************************************************************/
9322
9323bool lp_preferred_master(void)
9324{
9325 if (Globals.iPreferredMaster == Auto)
9326 return (lp_local_master() && lp_domain_master());
9327
9328 return (bool)Globals.iPreferredMaster;
9329}
9330
9331/*******************************************************************
9332 Remove a service.
9333********************************************************************/
9334
9335void lp_remove_service(int snum)
9336{
9337 ServicePtrs[snum]->valid = False;
9338 invalid_services[num_invalid_services++] = snum;
9339}
9340
9341/*******************************************************************
9342 Copy a service.
9343********************************************************************/
9344
9345void lp_copy_service(int snum, const char *new_name)
9346{
9347 do_section(new_name, NULL);
9348 if (snum >= 0) {
9349 snum = lp_servicenumber(new_name);
9350 if (snum >= 0)
9351 lp_do_parameter(snum, "copy", lp_servicename(snum));
9352 }
9353}
9354
9355
9356/*******************************************************************
9357 Get the default server type we will announce as via nmbd.
9358********************************************************************/
9359
9360int lp_default_server_announce(void)
9361{
9362 return default_server_announce;
9363}
9364
9365/*******************************************************************
9366 Split the announce version into major and minor numbers.
9367********************************************************************/
9368
9369int lp_major_announce_version(void)
9370{
9371 static bool got_major = False;
9372 static int major_version = DEFAULT_MAJOR_VERSION;
9373 char *vers;
9374 char *p;
9375
9376 if (got_major)
9377 return major_version;
9378
9379 got_major = True;
9380 if ((vers = lp_announce_version()) == NULL)
9381 return major_version;
9382
9383 if ((p = strchr_m(vers, '.')) == 0)
9384 return major_version;
9385
9386 *p = '\0';
9387 major_version = atoi(vers);
9388 return major_version;
9389}
9390
9391int lp_minor_announce_version(void)
9392{
9393 static bool got_minor = False;
9394 static int minor_version = DEFAULT_MINOR_VERSION;
9395 char *vers;
9396 char *p;
9397
9398 if (got_minor)
9399 return minor_version;
9400
9401 got_minor = True;
9402 if ((vers = lp_announce_version()) == NULL)
9403 return minor_version;
9404
9405 if ((p = strchr_m(vers, '.')) == 0)
9406 return minor_version;
9407
9408 p++;
9409 minor_version = atoi(p);
9410 return minor_version;
9411}
9412
9413/***********************************************************
9414 Set the global name resolution order (used in smbclient).
9415************************************************************/
9416
9417void lp_set_name_resolve_order(const char *new_order)
9418{
9419 string_set(&Globals.szNameResolveOrder, new_order);
9420}
9421
9422const char *lp_printername(int snum)
9423{
9424 const char *ret = _lp_printername(snum);
9425 if (ret == NULL || (ret != NULL && *ret == '\0'))
9426 ret = lp_const_servicename(snum);
9427
9428 return ret;
9429}
9430
9431
9432/***********************************************************
9433 Allow daemons such as winbindd to fix their logfile name.
9434************************************************************/
9435
9436void lp_set_logfile(const char *name)
9437{
9438 string_set(&Globals.szLogFile, name);
9439 debug_set_logfile(name);
9440}
9441
9442/*******************************************************************
9443 Return the max print jobs per queue.
9444********************************************************************/
9445
9446int lp_maxprintjobs(int snum)
9447{
9448 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9449 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9450 maxjobs = PRINT_MAX_JOBID - 1;
9451
9452 return maxjobs;
9453}
9454
9455const char *lp_printcapname(void)
9456{
9457 if ((Globals.szPrintcapname != NULL) &&
9458 (Globals.szPrintcapname[0] != '\0'))
9459 return Globals.szPrintcapname;
9460
9461 if (sDefault.iPrinting == PRINT_CUPS) {
9462#ifdef HAVE_CUPS
9463 return "cups";
9464#else
9465 return "lpstat";
9466#endif
9467 }
9468
9469 if (sDefault.iPrinting == PRINT_BSD)
9470 return "/etc/printcap";
9471
9472 return PRINTCAP_NAME;
9473}
9474
9475/*******************************************************************
9476 Ensure we don't use sendfile if server smb signing is active.
9477********************************************************************/
9478
9479static uint32 spoolss_state;
9480
9481bool lp_disable_spoolss( void )
9482{
9483 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9484 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9485
9486 return spoolss_state == SVCCTL_STOPPED ? True : False;
9487}
9488
9489void lp_set_spoolss_state( uint32 state )
9490{
9491 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9492
9493 spoolss_state = state;
9494}
9495
9496uint32 lp_get_spoolss_state( void )
9497{
9498 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9499}
9500
9501/*******************************************************************
9502 Ensure we don't use sendfile if server smb signing is active.
9503********************************************************************/
9504
9505bool lp_use_sendfile(int snum)
9506{
9507 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9508 if (Protocol < PROTOCOL_NT1) {
9509 return False;
9510 }
9511 return (_lp_use_sendfile(snum) &&
9512 (get_remote_arch() != RA_WIN95) &&
9513 !srv_is_signing_active());
9514}
9515
9516/*******************************************************************
9517 Turn off sendfile if we find the underlying OS doesn't support it.
9518********************************************************************/
9519
9520void set_use_sendfile(int snum, bool val)
9521{
9522 if (LP_SNUM_OK(snum))
9523 ServicePtrs[snum]->bUseSendfile = val;
9524 else
9525 sDefault.bUseSendfile = val;
9526}
9527
9528/*******************************************************************
9529 Turn off storing DOS attributes if this share doesn't support it.
9530********************************************************************/
9531
9532void set_store_dos_attributes(int snum, bool val)
9533{
9534 if (!LP_SNUM_OK(snum))
9535 return;
9536 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9537}
9538
9539void lp_set_mangling_method(const char *new_method)
9540{
9541 string_set(&Globals.szManglingMethod, new_method);
9542}
9543
9544/*******************************************************************
9545 Global state for POSIX pathname processing.
9546********************************************************************/
9547
9548static bool posix_pathnames;
9549
9550bool lp_posix_pathnames(void)
9551{
9552 return posix_pathnames;
9553}
9554
9555/*******************************************************************
9556 Change everything needed to ensure POSIX pathname processing (currently
9557 not much).
9558********************************************************************/
9559
9560void lp_set_posix_pathnames(void)
9561{
9562 posix_pathnames = True;
9563}
9564
9565/*******************************************************************
9566 Global state for POSIX lock processing - CIFS unix extensions.
9567********************************************************************/
9568
9569bool posix_default_lock_was_set;
9570static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9571
9572enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9573{
9574 if (posix_default_lock_was_set) {
9575 return posix_cifsx_locktype;
9576 } else {
9577 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9578 }
9579}
9580
9581/*******************************************************************
9582********************************************************************/
9583
9584void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9585{
9586 posix_default_lock_was_set = True;
9587 posix_cifsx_locktype = val;
9588}
9589
9590int lp_min_receive_file_size(void)
9591{
9592 if (Globals.iminreceivefile < 0) {
9593 return 0;
9594 }
9595 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9596}
9597
9598/*******************************************************************
9599 If socket address is an empty character string, it is necessary to
9600 define it as "0.0.0.0".
9601********************************************************************/
9602
9603const char *lp_socket_address(void)
9604{
9605 char *sock_addr = Globals.szSocketAddress;
9606
9607 if (sock_addr[0] == '\0'){
9608 string_set(&Globals.szSocketAddress, "0.0.0.0");
9609 }
9610 return Globals.szSocketAddress;
9611}
Note: See TracBrowser for help on using the repository browser.