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

Last change on this file since 689 was 689, checked in by Silvan Scherrer, 13 years ago

Samba 3.3: fixed ticket 192

File size: 255.9 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#ifdef __OS2__
85static bool newLockDir = False;
86#endif
87
88#define CONFIG_BACKEND_FILE 0
89#define CONFIG_BACKEND_REGISTRY 1
90
91static int config_backend = CONFIG_BACKEND_FILE;
92
93/* some helpful bits */
94#define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
95#define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
96
97#define USERSHARE_VALID 1
98#define USERSHARE_PENDING_DELETE 2
99
100extern int extra_time_offset;
101
102static bool defaults_saved = False;
103
104struct param_opt_struct {
105 struct param_opt_struct *prev, *next;
106 char *key;
107 char *value;
108 char **list;
109};
110
111/*
112 * This structure describes global (ie., server-wide) parameters.
113 */
114struct global {
115 int ConfigBackend;
116 char *smb_ports;
117 char *dos_charset;
118 char *unix_charset;
119 char *display_charset;
120 char *szPrintcapname;
121 char *szAddPortCommand;
122 char *szEnumPortsCommand;
123 char *szAddPrinterCommand;
124 char *szDeletePrinterCommand;
125 char *szOs2DriverMap;
126 char *szLockDir;
127 char *szPidDir;
128 char *szRootdir;
129 char *szDefaultService;
130 char *szGetQuota;
131 char *szSetQuota;
132 char *szMsgCommand;
133 char *szServerString;
134 char *szAutoServices;
135 char *szPasswdProgram;
136 char *szPasswdChat;
137 char *szLogFile;
138 char *szConfigFile;
139 char *szSMBPasswdFile;
140 char *szPrivateDir;
141 char *szPassdbBackend;
142 char **szPreloadModules;
143 char *szPasswordServer;
144 char *szSocketOptions;
145 char *szRealm;
146 char *szAfsUsernameMap;
147 int iAfsTokenLifetime;
148 char *szLogNtTokenCommand;
149 char *szUsernameMap;
150 char *szLogonScript;
151 char *szLogonPath;
152 char *szLogonDrive;
153 char *szLogonHome;
154 char **szWINSservers;
155 char **szInterfaces;
156 char *szRemoteAnnounce;
157 char *szRemoteBrowseSync;
158 char *szSocketAddress;
159 char *szNISHomeMapName;
160 char *szAnnounceVersion; /* This is initialised in init_globals */
161 char *szWorkgroup;
162 char *szNetbiosName;
163 char **szNetbiosAliases;
164 char *szNetbiosScope;
165 char *szNameResolveOrder;
166 char *szPanicAction;
167 char *szAddUserScript;
168 char *szRenameUserScript;
169 char *szDelUserScript;
170 char *szAddGroupScript;
171 char *szDelGroupScript;
172 char *szAddUserToGroupScript;
173 char *szDelUserFromGroupScript;
174 char *szSetPrimaryGroupScript;
175 char *szAddMachineScript;
176 char *szShutdownScript;
177 char *szAbortShutdownScript;
178 char *szUsernameMapScript;
179 char *szCheckPasswordScript;
180 char *szWINSHook;
181 char *szUtmpDir;
182 char *szWtmpDir;
183 bool bUtmp;
184 char *szIdmapUID;
185 char *szIdmapGID;
186 bool bPassdbExpandExplicit;
187 int AlgorithmicRidBase;
188 char *szTemplateHomedir;
189 char *szTemplateShell;
190 char *szWinbindSeparator;
191 bool bWinbindEnumUsers;
192 bool bWinbindEnumGroups;
193 bool bWinbindUseDefaultDomain;
194 bool bWinbindTrustedDomainsOnly;
195 bool bWinbindNestedGroups;
196 int winbind_expand_groups;
197 bool bWinbindRefreshTickets;
198 bool bWinbindOfflineLogon;
199 bool bWinbindNormalizeNames;
200 bool bWinbindRpcOnly;
201 char *szIdmapBackend;
202 char *szIdmapAllocBackend;
203 char *szAddShareCommand;
204 char *szChangeShareCommand;
205 char *szDeleteShareCommand;
206 char **szEventLogs;
207 char *szGuestaccount;
208 char *szManglingMethod;
209 char **szServicesList;
210 char *szUsersharePath;
211 char *szUsershareTemplateShare;
212 char **szUsersharePrefixAllowList;
213 char **szUsersharePrefixDenyList;
214 int mangle_prefix;
215 int max_log_size;
216 char *szLogLevel;
217 int max_xmit;
218 int max_mux;
219 int max_open_files;
220 int open_files_db_hash_size;
221 int pwordlevel;
222 int unamelevel;
223 int deadtime;
224 bool getwd_cache;
225 int maxprotocol;
226 int minprotocol;
227 int security;
228 char **AuthMethods;
229 bool paranoid_server_security;
230 int maxdisksize;
231 int lpqcachetime;
232 int iMaxSmbdProcesses;
233 bool bDisableSpoolss;
234 int syslog;
235 int os_level;
236 bool enhanced_browsing;
237 int max_ttl;
238 int max_wins_ttl;
239 int min_wins_ttl;
240 int lm_announce;
241 int lm_interval;
242 int announce_as; /* This is initialised in init_globals */
243 int machine_password_timeout;
244 int map_to_guest;
245 int oplock_break_wait_time;
246 int winbind_cache_time;
247 int winbind_reconnect_delay;
248 int winbind_max_idle_children;
249 char **szWinbindNssInfo;
250 int iLockSpinTime;
251 char *szLdapMachineSuffix;
252 char *szLdapUserSuffix;
253 char *szLdapIdmapSuffix;
254 char *szLdapGroupSuffix;
255 int ldap_ssl;
256 bool ldap_ssl_ads;
257 char *szLdapSuffix;
258 char *szLdapAdminDn;
259 int ldap_debug_level;
260 int ldap_debug_threshold;
261 int iAclCompat;
262 char *szCupsServer;
263 char *szIPrintServer;
264 char *ctdbdSocket;
265 char **szClusterAddresses;
266 bool clustering;
267 int ldap_passwd_sync;
268 int ldap_replication_sleep;
269 int ldap_timeout; /* This is initialised in init_globals */
270 int ldap_connection_timeout;
271 int ldap_page_size;
272 bool ldap_delete_dn;
273 bool bMsAddPrinterWizard;
274 bool bDNSproxy;
275 bool bWINSsupport;
276 bool bWINSproxy;
277 bool bLocalMaster;
278 int iPreferredMaster;
279 int iDomainMaster;
280 bool bDomainLogons;
281 char **szInitLogonDelayedHosts;
282 int InitLogonDelay;
283 bool bEncryptPasswords;
284 bool bUpdateEncrypt;
285 int clientSchannel;
286 int serverSchannel;
287 bool bNullPasswords;
288 bool bObeyPamRestrictions;
289 bool bLoadPrinters;
290 int PrintcapCacheTime;
291 bool bLargeReadwrite;
292 bool bReadRaw;
293 bool bWriteRaw;
294 bool bSyslogOnly;
295 bool bBrowseList;
296 bool bNISHomeMap;
297 bool bTimeServer;
298 bool bBindInterfacesOnly;
299 bool bPamPasswordChange;
300 bool bUnixPasswdSync;
301 bool bPasswdChatDebug;
302 int iPasswdChatTimeout;
303 bool bTimestampLogs;
304 bool bNTSmbSupport;
305 bool bNTPipeSupport;
306 bool bNTStatusSupport;
307 bool bStatCache;
308 int iMaxStatCacheSize;
309 bool bKernelOplocks;
310 bool bAllowTrustedDomains;
311 bool bLanmanAuth;
312 bool bNTLMAuth;
313 bool bUseSpnego;
314 bool bClientLanManAuth;
315 bool bClientNTLMv2Auth;
316 bool bClientPlaintextAuth;
317 bool bClientUseSpnego;
318 bool bDebugPrefixTimestamp;
319 bool bDebugHiresTimestamp;
320 bool bDebugPid;
321 bool bDebugUid;
322 bool bDebugClass;
323 bool bEnableCoreFiles;
324 bool bHostMSDfs;
325 bool bUseMmap;
326 bool bHostnameLookups;
327 bool bUnixExtensions;
328 bool bDisableNetbios;
329 bool bUseKerberosKeytab;
330 bool bDeferSharingViolations;
331 bool bEnablePrivileges;
332 bool bASUSupport;
333 bool bUsershareOwnerOnly;
334 bool bUsershareAllowGuests;
335 bool bRegistryShares;
336 int restrict_anonymous;
337 int name_cache_timeout;
338 int client_signing;
339 int server_signing;
340 int client_ldap_sasl_wrapping;
341 int iUsershareMaxShares;
342 int iIdmapCacheTime;
343 int iIdmapNegativeCacheTime;
344 bool bResetOnZeroVC;
345 int iKeepalive;
346 int iminreceivefile;
347 struct param_opt_struct *param_opt;
348 int cups_connection_timeout;
349};
350
351static struct global Globals;
352
353/*
354 * This structure describes a single service.
355 */
356struct service {
357 bool valid;
358 bool autoloaded;
359 int usershare;
360 time_t usershare_last_mod;
361 char *szService;
362 char *szPath;
363 char *szUsername;
364 char **szInvalidUsers;
365 char **szValidUsers;
366 char **szAdminUsers;
367 char *szCopy;
368 char *szInclude;
369 char *szPreExec;
370 char *szPostExec;
371 char *szRootPreExec;
372 char *szRootPostExec;
373 char *szCupsOptions;
374 char *szPrintcommand;
375 char *szLpqcommand;
376 char *szLprmcommand;
377 char *szLppausecommand;
378 char *szLpresumecommand;
379 char *szQueuepausecommand;
380 char *szQueueresumecommand;
381 char *szPrintername;
382 char *szPrintjobUsername;
383 char *szDontdescend;
384 char **szHostsallow;
385 char **szHostsdeny;
386 char *szMagicScript;
387 char *szMagicOutput;
388 char *szVetoFiles;
389 char *szHideFiles;
390 char *szVetoOplockFiles;
391 char *comment;
392 char *force_user;
393 char *force_group;
394 char **readlist;
395 char **writelist;
396 char **printer_admin;
397 char *volume;
398 char *fstype;
399 char **szVfsObjects;
400 char *szMSDfsProxy;
401 char *szAioWriteBehind;
402 char *szDfree;
403 int iMinPrintSpace;
404 int iMaxPrintJobs;
405 int iMaxReportedPrintJobs;
406 int iWriteCacheSize;
407 int iCreate_mask;
408 int iCreate_force_mode;
409 int iSecurity_mask;
410 int iSecurity_force_mode;
411 int iDir_mask;
412 int iDir_force_mode;
413 int iDir_Security_mask;
414 int iDir_Security_force_mode;
415 int iMaxConnections;
416 int iDefaultCase;
417 int iPrinting;
418 int iOplockContentionLimit;
419 int iCSCPolicy;
420 int iBlock_size;
421 int iDfreeCacheTime;
422 bool bPreexecClose;
423 bool bRootpreexecClose;
424 int iCaseSensitive;
425 bool bCasePreserve;
426 bool bShortCasePreserve;
427 bool bHideDotFiles;
428 bool bHideSpecialFiles;
429 bool bHideUnReadable;
430 bool bHideUnWriteableFiles;
431 bool bBrowseable;
432 bool bAvailable;
433 bool bRead_only;
434 bool bNo_set_dir;
435 bool bGuest_only;
436 bool bAdministrative_share;
437 bool bGuest_ok;
438 bool bPrint_ok;
439 bool bMap_system;
440 bool bMap_hidden;
441 bool bMap_archive;
442 bool bStoreDosAttributes;
443 bool bDmapiSupport;
444 bool bLocking;
445 int iStrictLocking;
446 bool bPosixLocking;
447 bool bShareModes;
448 bool bOpLocks;
449 bool bLevel2OpLocks;
450 bool bOnlyUser;
451 bool bMangledNames;
452 bool bWidelinks;
453 bool bSymlinks;
454 bool bSyncAlways;
455 bool bStrictAllocate;
456 bool bStrictSync;
457 char magic_char;
458 struct bitmap *copymap;
459 bool bDeleteReadonly;
460 bool bFakeOplocks;
461 bool bDeleteVetoFiles;
462 bool bDosFilemode;
463 bool bDosFiletimes;
464 bool bDosFiletimeResolution;
465 bool bFakeDirCreateTimes;
466 bool bBlockingLocks;
467 bool bInheritPerms;
468 bool bInheritACLS;
469 bool bInheritOwner;
470 bool bMSDfsRoot;
471 bool bUseClientDriver;
472 bool bDefaultDevmode;
473 bool bForcePrintername;
474 bool bNTAclSupport;
475 bool bForceUnknownAclUser;
476 bool bUseSendfile;
477 bool bProfileAcls;
478 bool bMap_acl_inherit;
479 bool bAfs_Share;
480 bool bEASupport;
481 bool bAclCheckPermissions;
482 bool bAclMapFullControl;
483 bool bAclGroupControl;
484 bool bChangeNotify;
485 bool bKernelChangeNotify;
486 int iallocation_roundup_size;
487 int iAioReadSize;
488 int iAioWriteSize;
489 int iMap_readonly;
490 int iDirectoryNameCacheSize;
491 int ismb_encrypt;
492 struct param_opt_struct *param_opt;
493
494 char dummy[3]; /* for alignment */
495};
496
497
498/* This is a default service used to prime a services structure */
499static struct service sDefault = {
500 True, /* valid */
501 False, /* not autoloaded */
502 0, /* not a usershare */
503 (time_t)0, /* No last mod time */
504 NULL, /* szService */
505 NULL, /* szPath */
506 NULL, /* szUsername */
507 NULL, /* szInvalidUsers */
508 NULL, /* szValidUsers */
509 NULL, /* szAdminUsers */
510 NULL, /* szCopy */
511 NULL, /* szInclude */
512 NULL, /* szPreExec */
513 NULL, /* szPostExec */
514 NULL, /* szRootPreExec */
515 NULL, /* szRootPostExec */
516 NULL, /* szCupsOptions */
517 NULL, /* szPrintcommand */
518 NULL, /* szLpqcommand */
519 NULL, /* szLprmcommand */
520 NULL, /* szLppausecommand */
521 NULL, /* szLpresumecommand */
522 NULL, /* szQueuepausecommand */
523 NULL, /* szQueueresumecommand */
524 NULL, /* szPrintername */
525 NULL, /* szPrintjobUsername */
526 NULL, /* szDontdescend */
527 NULL, /* szHostsallow */
528 NULL, /* szHostsdeny */
529 NULL, /* szMagicScript */
530 NULL, /* szMagicOutput */
531 NULL, /* szVetoFiles */
532 NULL, /* szHideFiles */
533 NULL, /* szVetoOplockFiles */
534 NULL, /* comment */
535 NULL, /* force user */
536 NULL, /* force group */
537 NULL, /* readlist */
538 NULL, /* writelist */
539 NULL, /* printer admin */
540 NULL, /* volume */
541 NULL, /* fstype */
542 NULL, /* vfs objects */
543 NULL, /* szMSDfsProxy */
544 NULL, /* szAioWriteBehind */
545 NULL, /* szDfree */
546 0, /* iMinPrintSpace */
547 1000, /* iMaxPrintJobs */
548 0, /* iMaxReportedPrintJobs */
549 0, /* iWriteCacheSize */
550 0744, /* iCreate_mask */
551 0000, /* iCreate_force_mode */
552 0777, /* iSecurity_mask */
553 0, /* iSecurity_force_mode */
554 0755, /* iDir_mask */
555 0000, /* iDir_force_mode */
556 0777, /* iDir_Security_mask */
557 0, /* iDir_Security_force_mode */
558 0, /* iMaxConnections */
559 CASE_LOWER, /* iDefaultCase */
560 DEFAULT_PRINTING, /* iPrinting */
561 2, /* iOplockContentionLimit */
562 0, /* iCSCPolicy */
563 1024, /* iBlock_size */
564 0, /* iDfreeCacheTime */
565 False, /* bPreexecClose */
566 False, /* bRootpreexecClose */
567 Auto, /* case sensitive */
568 True, /* case preserve */
569 True, /* short case preserve */
570 True, /* bHideDotFiles */
571 False, /* bHideSpecialFiles */
572 False, /* bHideUnReadable */
573 False, /* bHideUnWriteableFiles */
574 True, /* bBrowseable */
575 True, /* bAvailable */
576 True, /* bRead_only */
577 True, /* bNo_set_dir */
578 False, /* bGuest_only */
579 False, /* bAdministrative_share */
580 False, /* bGuest_ok */
581 False, /* bPrint_ok */
582 False, /* bMap_system */
583 False, /* bMap_hidden */
584 True, /* bMap_archive */
585 False, /* bStoreDosAttributes */
586 False, /* bDmapiSupport */
587 True, /* bLocking */
588 Auto, /* iStrictLocking */
589 True, /* bPosixLocking */
590 True, /* bShareModes */
591 True, /* bOpLocks */
592 True, /* bLevel2OpLocks */
593 False, /* bOnlyUser */
594 True, /* bMangledNames */
595 False, /* bWidelinks */
596 True, /* bSymlinks */
597 False, /* bSyncAlways */
598 False, /* bStrictAllocate */
599 False, /* bStrictSync */
600 '~', /* magic char */
601 NULL, /* copymap */
602 False, /* bDeleteReadonly */
603 False, /* bFakeOplocks */
604 False, /* bDeleteVetoFiles */
605 False, /* bDosFilemode */
606 True, /* bDosFiletimes */
607 False, /* bDosFiletimeResolution */
608 False, /* bFakeDirCreateTimes */
609 True, /* bBlockingLocks */
610 False, /* bInheritPerms */
611 False, /* bInheritACLS */
612 False, /* bInheritOwner */
613 False, /* bMSDfsRoot */
614 False, /* bUseClientDriver */
615 True, /* bDefaultDevmode */
616 False, /* bForcePrintername */
617 True, /* bNTAclSupport */
618 False, /* bForceUnknownAclUser */
619 False, /* bUseSendfile */
620 False, /* bProfileAcls */
621 False, /* bMap_acl_inherit */
622 False, /* bAfs_Share */
623 False, /* bEASupport */
624 True, /* bAclCheckPermissions */
625 True, /* bAclMapFullControl */
626 False, /* bAclGroupControl */
627 True, /* bChangeNotify */
628 True, /* bKernelChangeNotify */
629 SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
630 0, /* iAioReadSize */
631 0, /* iAioWriteSize */
632 MAP_READONLY_YES, /* iMap_readonly */
633#ifdef BROKEN_DIRECTORY_HANDLING
634 0, /* iDirectoryNameCacheSize */
635#else
636 100, /* iDirectoryNameCacheSize */
637#endif
638 Auto, /* ismb_encrypt */
639 NULL, /* Parametric options */
640
641 "" /* dummy */
642};
643
644/* local variables */
645static struct service **ServicePtrs = NULL;
646static int iNumServices = 0;
647static int iServiceIndex = 0;
648static struct db_context *ServiceHash;
649static int *invalid_services = NULL;
650static int num_invalid_services = 0;
651static bool bInGlobalSection = True;
652static bool bGlobalOnly = False;
653static int server_role;
654static int default_server_announce;
655
656#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
657
658/* prototypes for the special type handlers */
659static bool handle_include( int snum, const char *pszParmValue, char **ptr);
660static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
661static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
662static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
663static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
664static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
665static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
666static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
667static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
668static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
669static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
670static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
671
672static void set_server_role(void);
673static void set_default_server_announce_type(void);
674static void set_allowed_client_auth(void);
675
676static void add_to_file_list(const char *fname, const char *subfname);
677
678static const struct enum_list enum_protocol[] = {
679 {PROTOCOL_NT1, "NT1"},
680 {PROTOCOL_LANMAN2, "LANMAN2"},
681 {PROTOCOL_LANMAN1, "LANMAN1"},
682 {PROTOCOL_CORE, "CORE"},
683 {PROTOCOL_COREPLUS, "COREPLUS"},
684 {PROTOCOL_COREPLUS, "CORE+"},
685 {-1, NULL}
686};
687
688static const struct enum_list enum_security[] = {
689 {SEC_SHARE, "SHARE"},
690 {SEC_USER, "USER"},
691 {SEC_SERVER, "SERVER"},
692 {SEC_DOMAIN, "DOMAIN"},
693#ifdef HAVE_ADS
694 {SEC_ADS, "ADS"},
695#endif
696 {-1, NULL}
697};
698
699static const struct enum_list enum_printing[] = {
700 {PRINT_SYSV, "sysv"},
701 {PRINT_AIX, "aix"},
702 {PRINT_HPUX, "hpux"},
703 {PRINT_BSD, "bsd"},
704 {PRINT_QNX, "qnx"},
705 {PRINT_PLP, "plp"},
706 {PRINT_LPRNG, "lprng"},
707 {PRINT_CUPS, "cups"},
708 {PRINT_IPRINT, "iprint"},
709 {PRINT_LPRNT, "nt"},
710 {PRINT_LPROS2, "os2"},
711#ifdef DEVELOPER
712 {PRINT_TEST, "test"},
713 {PRINT_VLP, "vlp"},
714#endif /* DEVELOPER */
715 {-1, NULL}
716};
717
718static const struct enum_list enum_ldap_sasl_wrapping[] = {
719 {0, "plain"},
720 {ADS_AUTH_SASL_SIGN, "sign"},
721 {ADS_AUTH_SASL_SEAL, "seal"},
722 {-1, NULL}
723};
724
725static const struct enum_list enum_ldap_ssl[] = {
726 {LDAP_SSL_OFF, "no"},
727 {LDAP_SSL_OFF, "off"},
728 {LDAP_SSL_START_TLS, "start tls"},
729 {LDAP_SSL_START_TLS, "start_tls"},
730 {-1, NULL}
731};
732
733static const struct enum_list enum_ldap_passwd_sync[] = {
734 {LDAP_PASSWD_SYNC_OFF, "no"},
735 {LDAP_PASSWD_SYNC_OFF, "off"},
736 {LDAP_PASSWD_SYNC_ON, "yes"},
737 {LDAP_PASSWD_SYNC_ON, "on"},
738 {LDAP_PASSWD_SYNC_ONLY, "only"},
739 {-1, NULL}
740};
741
742/* Types of machine we can announce as. */
743#define ANNOUNCE_AS_NT_SERVER 1
744#define ANNOUNCE_AS_WIN95 2
745#define ANNOUNCE_AS_WFW 3
746#define ANNOUNCE_AS_NT_WORKSTATION 4
747
748static const struct enum_list enum_announce_as[] = {
749 {ANNOUNCE_AS_NT_SERVER, "NT"},
750 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
751 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
752 {ANNOUNCE_AS_WIN95, "win95"},
753 {ANNOUNCE_AS_WFW, "WfW"},
754 {-1, NULL}
755};
756
757static const struct enum_list enum_map_readonly[] = {
758 {MAP_READONLY_NO, "no"},
759 {MAP_READONLY_NO, "false"},
760 {MAP_READONLY_NO, "0"},
761 {MAP_READONLY_YES, "yes"},
762 {MAP_READONLY_YES, "true"},
763 {MAP_READONLY_YES, "1"},
764 {MAP_READONLY_PERMISSIONS, "permissions"},
765 {MAP_READONLY_PERMISSIONS, "perms"},
766 {-1, NULL}
767};
768
769static const struct enum_list enum_case[] = {
770 {CASE_LOWER, "lower"},
771 {CASE_UPPER, "upper"},
772 {-1, NULL}
773};
774
775static const struct enum_list enum_bool_auto[] = {
776 {False, "No"},
777 {False, "False"},
778 {False, "0"},
779 {True, "Yes"},
780 {True, "True"},
781 {True, "1"},
782 {Auto, "Auto"},
783 {-1, NULL}
784};
785
786/* Client-side offline caching policy types */
787#define CSC_POLICY_MANUAL 0
788#define CSC_POLICY_DOCUMENTS 1
789#define CSC_POLICY_PROGRAMS 2
790#define CSC_POLICY_DISABLE 3
791
792static const struct enum_list enum_csc_policy[] = {
793 {CSC_POLICY_MANUAL, "manual"},
794 {CSC_POLICY_DOCUMENTS, "documents"},
795 {CSC_POLICY_PROGRAMS, "programs"},
796 {CSC_POLICY_DISABLE, "disable"},
797 {-1, NULL}
798};
799
800/* SMB signing types. */
801static const struct enum_list enum_smb_signing_vals[] = {
802 {False, "No"},
803 {False, "False"},
804 {False, "0"},
805 {False, "Off"},
806 {False, "disabled"},
807 {True, "Yes"},
808 {True, "True"},
809 {True, "1"},
810 {True, "On"},
811 {True, "enabled"},
812 {Auto, "auto"},
813 {Required, "required"},
814 {Required, "mandatory"},
815 {Required, "force"},
816 {Required, "forced"},
817 {Required, "enforced"},
818 {-1, NULL}
819};
820
821/* ACL compatibility options. */
822static const struct enum_list enum_acl_compat_vals[] = {
823 { ACL_COMPAT_AUTO, "auto" },
824 { ACL_COMPAT_WINNT, "winnt" },
825 { ACL_COMPAT_WIN2K, "win2k" },
826 { -1, NULL}
827};
828
829/*
830 Do you want session setups at user level security with a invalid
831 password to be rejected or allowed in as guest? WinNT rejects them
832 but it can be a pain as it means "net view" needs to use a password
833
834 You have 3 choices in the setting of map_to_guest:
835
836 "Never" means session setups with an invalid password
837 are rejected. This is the default.
838
839 "Bad User" means session setups with an invalid password
840 are rejected, unless the username does not exist, in which case it
841 is treated as a guest login
842
843 "Bad Password" means session setups with an invalid password
844 are treated as a guest login
845
846 Note that map_to_guest only has an effect in user or server
847 level security.
848*/
849
850static const struct enum_list enum_map_to_guest[] = {
851 {NEVER_MAP_TO_GUEST, "Never"},
852 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
853 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
854 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
855 {-1, NULL}
856};
857
858/* Config backend options */
859
860static const struct enum_list enum_config_backend[] = {
861 {CONFIG_BACKEND_FILE, "file"},
862 {CONFIG_BACKEND_REGISTRY, "registry"},
863 {-1, NULL}
864};
865
866/* Note: We do not initialise the defaults union - it is not allowed in ANSI C
867 *
868 * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
869 * screen in SWAT. This is used to exclude parameters as well as to squash all
870 * parameters that have been duplicated by pseudonyms.
871 *
872 * NOTE: To display a parameter in BASIC view set FLAG_BASIC
873 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all
874 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
875 * respective views.
876 *
877 * NOTE2: Handling of duplicated (synonym) parameters:
878 * Only the first occurance of a parameter should be enabled by FLAG_BASIC
879 * and/or FLAG_ADVANCED. All duplicates following the first mention should be
880 * set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
881 * name first, and all synonyms must follow it with the FLAG_HIDE attribute.
882 */
883
884static struct parm_struct parm_table[] = {
885 {N_("Base Options"), P_SEP, P_SEPARATOR},
886
887 {
888 .label = "dos charset",
889 .type = P_STRING,
890 .p_class = P_GLOBAL,
891 .ptr = &Globals.dos_charset,
892 .special = handle_charset,
893 .enum_list = NULL,
894 .flags = FLAG_ADVANCED
895 },
896 {
897 .label = "unix charset",
898 .type = P_STRING,
899 .p_class = P_GLOBAL,
900 .ptr = &Globals.unix_charset,
901 .special = handle_charset,
902 .enum_list = NULL,
903 .flags = FLAG_ADVANCED
904 },
905 {
906 .label = "display charset",
907 .type = P_STRING,
908 .p_class = P_GLOBAL,
909 .ptr = &Globals.display_charset,
910 .special = handle_charset,
911 .enum_list = NULL,
912 .flags = FLAG_ADVANCED
913 },
914 {
915 .label = "comment",
916 .type = P_STRING,
917 .p_class = P_LOCAL,
918 .ptr = &sDefault.comment,
919 .special = NULL,
920 .enum_list = NULL,
921 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
922 },
923 {
924 .label = "path",
925 .type = P_STRING,
926 .p_class = P_LOCAL,
927 .ptr = &sDefault.szPath,
928 .special = NULL,
929 .enum_list = NULL,
930 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
931 },
932 {
933 .label = "directory",
934 .type = P_STRING,
935 .p_class = P_LOCAL,
936 .ptr = &sDefault.szPath,
937 .special = NULL,
938 .enum_list = NULL,
939 .flags = FLAG_HIDE,
940 },
941 {
942 .label = "workgroup",
943 .type = P_USTRING,
944 .p_class = P_GLOBAL,
945 .ptr = &Globals.szWorkgroup,
946 .special = handle_workgroup,
947 .enum_list = NULL,
948 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
949 },
950#ifdef WITH_ADS
951 {
952 .label = "realm",
953 .type = P_USTRING,
954 .p_class = P_GLOBAL,
955 .ptr = &Globals.szRealm,
956 .special = NULL,
957 .enum_list = NULL,
958 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
959 },
960#endif
961 {
962 .label = "netbios name",
963 .type = P_USTRING,
964 .p_class = P_GLOBAL,
965 .ptr = &Globals.szNetbiosName,
966 .special = handle_netbios_name,
967 .enum_list = NULL,
968 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
969 },
970 {
971 .label = "netbios aliases",
972 .type = P_LIST,
973 .p_class = P_GLOBAL,
974 .ptr = &Globals.szNetbiosAliases,
975 .special = handle_netbios_aliases,
976 .enum_list = NULL,
977 .flags = FLAG_ADVANCED,
978 },
979 {
980 .label = "netbios scope",
981 .type = P_USTRING,
982 .p_class = P_GLOBAL,
983 .ptr = &Globals.szNetbiosScope,
984 .special = handle_netbios_scope,
985 .enum_list = NULL,
986 .flags = FLAG_ADVANCED,
987 },
988 {
989 .label = "server string",
990 .type = P_STRING,
991 .p_class = P_GLOBAL,
992 .ptr = &Globals.szServerString,
993 .special = NULL,
994 .enum_list = NULL,
995 .flags = FLAG_BASIC | FLAG_ADVANCED,
996 },
997 {
998 .label = "interfaces",
999 .type = P_LIST,
1000 .p_class = P_GLOBAL,
1001 .ptr = &Globals.szInterfaces,
1002 .special = NULL,
1003 .enum_list = NULL,
1004 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1005 },
1006 {
1007 .label = "bind interfaces only",
1008 .type = P_BOOL,
1009 .p_class = P_GLOBAL,
1010 .ptr = &Globals.bBindInterfacesOnly,
1011 .special = NULL,
1012 .enum_list = NULL,
1013 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1014 },
1015 {
1016 .label = "config backend",
1017 .type = P_ENUM,
1018 .p_class = P_GLOBAL,
1019 .ptr = &Globals.ConfigBackend,
1020 .special = NULL,
1021 .enum_list = enum_config_backend,
1022 .flags = FLAG_ADVANCED,
1023 },
1024
1025 {N_("Security Options"), P_SEP, P_SEPARATOR},
1026
1027 {
1028 .label = "security",
1029 .type = P_ENUM,
1030 .p_class = P_GLOBAL,
1031 .ptr = &Globals.security,
1032 .special = NULL,
1033 .enum_list = enum_security,
1034 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1035 },
1036 {
1037 .label = "auth methods",
1038 .type = P_LIST,
1039 .p_class = P_GLOBAL,
1040 .ptr = &Globals.AuthMethods,
1041 .special = NULL,
1042 .enum_list = NULL,
1043 .flags = FLAG_ADVANCED,
1044 },
1045 {
1046 .label = "encrypt passwords",
1047 .type = P_BOOL,
1048 .p_class = P_GLOBAL,
1049 .ptr = &Globals.bEncryptPasswords,
1050 .special = NULL,
1051 .enum_list = NULL,
1052 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
1053 },
1054 {
1055 .label = "update encrypted",
1056 .type = P_BOOL,
1057 .p_class = P_GLOBAL,
1058 .ptr = &Globals.bUpdateEncrypt,
1059 .special = NULL,
1060 .enum_list = NULL,
1061 .flags = FLAG_ADVANCED,
1062 },
1063 {
1064 .label = "client schannel",
1065 .type = P_ENUM,
1066 .p_class = P_GLOBAL,
1067 .ptr = &Globals.clientSchannel,
1068 .special = NULL,
1069 .enum_list = enum_bool_auto,
1070 .flags = FLAG_BASIC | FLAG_ADVANCED,
1071 },
1072 {
1073 .label = "server schannel",
1074 .type = P_ENUM,
1075 .p_class = P_GLOBAL,
1076 .ptr = &Globals.serverSchannel,
1077 .special = NULL,
1078 .enum_list = enum_bool_auto,
1079 .flags = FLAG_BASIC | FLAG_ADVANCED,
1080 },
1081 {
1082 .label = "allow trusted domains",
1083 .type = P_BOOL,
1084 .p_class = P_GLOBAL,
1085 .ptr = &Globals.bAllowTrustedDomains,
1086 .special = NULL,
1087 .enum_list = NULL,
1088 .flags = FLAG_ADVANCED,
1089 },
1090 {
1091 .label = "map to guest",
1092 .type = P_ENUM,
1093 .p_class = P_GLOBAL,
1094 .ptr = &Globals.map_to_guest,
1095 .special = NULL,
1096 .enum_list = enum_map_to_guest,
1097 .flags = FLAG_ADVANCED,
1098 },
1099 {
1100 .label = "null passwords",
1101 .type = P_BOOL,
1102 .p_class = P_GLOBAL,
1103 .ptr = &Globals.bNullPasswords,
1104 .special = NULL,
1105 .enum_list = NULL,
1106 .flags = FLAG_ADVANCED,
1107 },
1108 {
1109 .label = "obey pam restrictions",
1110 .type = P_BOOL,
1111 .p_class = P_GLOBAL,
1112 .ptr = &Globals.bObeyPamRestrictions,
1113 .special = NULL,
1114 .enum_list = NULL,
1115 .flags = FLAG_ADVANCED,
1116 },
1117 {
1118 .label = "password server",
1119 .type = P_STRING,
1120 .p_class = P_GLOBAL,
1121 .ptr = &Globals.szPasswordServer,
1122 .special = NULL,
1123 .enum_list = NULL,
1124 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1125 },
1126 {
1127 .label = "smb passwd file",
1128 .type = P_STRING,
1129 .p_class = P_GLOBAL,
1130 .ptr = &Globals.szSMBPasswdFile,
1131 .special = NULL,
1132 .enum_list = NULL,
1133 .flags = FLAG_ADVANCED,
1134 },
1135 {
1136 .label = "private dir",
1137 .type = P_STRING,
1138 .p_class = P_GLOBAL,
1139 .ptr = &Globals.szPrivateDir,
1140 .special = NULL,
1141 .enum_list = NULL,
1142 .flags = FLAG_ADVANCED,
1143 },
1144 {
1145 .label = "passdb backend",
1146 .type = P_STRING,
1147 .p_class = P_GLOBAL,
1148 .ptr = &Globals.szPassdbBackend,
1149 .special = NULL,
1150 .enum_list = NULL,
1151 .flags = FLAG_ADVANCED | FLAG_WIZARD,
1152 },
1153 {
1154 .label = "algorithmic rid base",
1155 .type = P_INTEGER,
1156 .p_class = P_GLOBAL,
1157 .ptr = &Globals.AlgorithmicRidBase,
1158 .special = NULL,
1159 .enum_list = NULL,
1160 .flags = FLAG_ADVANCED,
1161 },
1162 {
1163 .label = "root directory",
1164 .type = P_STRING,
1165 .p_class = P_GLOBAL,
1166 .ptr = &Globals.szRootdir,
1167 .special = NULL,
1168 .enum_list = NULL,
1169 .flags = FLAG_ADVANCED,
1170 },
1171 {
1172 .label = "root dir",
1173 .type = P_STRING,
1174 .p_class = P_GLOBAL,
1175 .ptr = &Globals.szRootdir,
1176 .special = NULL,
1177 .enum_list = NULL,
1178 .flags = FLAG_HIDE,
1179 },
1180 {
1181 .label = "root",
1182 .type = P_STRING,
1183 .p_class = P_GLOBAL,
1184 .ptr = &Globals.szRootdir,
1185 .special = NULL,
1186 .enum_list = NULL,
1187 .flags = FLAG_HIDE,
1188 },
1189 {
1190 .label = "guest account",
1191 .type = P_STRING,
1192 .p_class = P_GLOBAL,
1193 .ptr = &Globals.szGuestaccount,
1194 .special = NULL,
1195 .enum_list = NULL,
1196 .flags = FLAG_BASIC | FLAG_ADVANCED,
1197 },
1198 {
1199 .label = "enable privileges",
1200 .type = P_BOOL,
1201 .p_class = P_GLOBAL,
1202 .ptr = &Globals.bEnablePrivileges,
1203 .special = NULL,
1204 .enum_list = NULL,
1205 .flags = FLAG_ADVANCED,
1206 },
1207
1208 {
1209 .label = "pam password change",
1210 .type = P_BOOL,
1211 .p_class = P_GLOBAL,
1212 .ptr = &Globals.bPamPasswordChange,
1213 .special = NULL,
1214 .enum_list = NULL,
1215 .flags = FLAG_ADVANCED,
1216 },
1217 {
1218 .label = "passwd program",
1219 .type = P_STRING,
1220 .p_class = P_GLOBAL,
1221 .ptr = &Globals.szPasswdProgram,
1222 .special = NULL,
1223 .enum_list = NULL,
1224 .flags = FLAG_ADVANCED,
1225 },
1226 {
1227 .label = "passwd chat",
1228 .type = P_STRING,
1229 .p_class = P_GLOBAL,
1230 .ptr = &Globals.szPasswdChat,
1231 .special = NULL,
1232 .enum_list = NULL,
1233 .flags = FLAG_ADVANCED,
1234 },
1235 {
1236 .label = "passwd chat debug",
1237 .type = P_BOOL,
1238 .p_class = P_GLOBAL,
1239 .ptr = &Globals.bPasswdChatDebug,
1240 .special = NULL,
1241 .enum_list = NULL,
1242 .flags = FLAG_ADVANCED,
1243 },
1244 {
1245 .label = "passwd chat timeout",
1246 .type = P_INTEGER,
1247 .p_class = P_GLOBAL,
1248 .ptr = &Globals.iPasswdChatTimeout,
1249 .special = NULL,
1250 .enum_list = NULL,
1251 .flags = FLAG_ADVANCED,
1252 },
1253 {
1254 .label = "check password script",
1255 .type = P_STRING,
1256 .p_class = P_GLOBAL,
1257 .ptr = &Globals.szCheckPasswordScript,
1258 .special = NULL,
1259 .enum_list = NULL,
1260 .flags = FLAG_ADVANCED,
1261 },
1262 {
1263 .label = "username map",
1264 .type = P_STRING,
1265 .p_class = P_GLOBAL,
1266 .ptr = &Globals.szUsernameMap,
1267 .special = NULL,
1268 .enum_list = NULL,
1269 .flags = FLAG_ADVANCED,
1270 },
1271 {
1272 .label = "password level",
1273 .type = P_INTEGER,
1274 .p_class = P_GLOBAL,
1275 .ptr = &Globals.pwordlevel,
1276 .special = NULL,
1277 .enum_list = NULL,
1278 .flags = FLAG_ADVANCED,
1279 },
1280 {
1281 .label = "username level",
1282 .type = P_INTEGER,
1283 .p_class = P_GLOBAL,
1284 .ptr = &Globals.unamelevel,
1285 .special = NULL,
1286 .enum_list = NULL,
1287 .flags = FLAG_ADVANCED,
1288 },
1289 {
1290 .label = "unix password sync",
1291 .type = P_BOOL,
1292 .p_class = P_GLOBAL,
1293 .ptr = &Globals.bUnixPasswdSync,
1294 .special = NULL,
1295 .enum_list = NULL,
1296 .flags = FLAG_ADVANCED,
1297 },
1298 {
1299 .label = "restrict anonymous",
1300 .type = P_INTEGER,
1301 .p_class = P_GLOBAL,
1302 .ptr = &Globals.restrict_anonymous,
1303 .special = NULL,
1304 .enum_list = NULL,
1305 .flags = FLAG_ADVANCED,
1306 },
1307 {
1308 .label = "lanman auth",
1309 .type = P_BOOL,
1310 .p_class = P_GLOBAL,
1311 .ptr = &Globals.bLanmanAuth,
1312 .special = NULL,
1313 .enum_list = NULL,
1314 .flags = FLAG_ADVANCED,
1315 },
1316 {
1317 .label = "ntlm auth",
1318 .type = P_BOOL,
1319 .p_class = P_GLOBAL,
1320 .ptr = &Globals.bNTLMAuth,
1321 .special = NULL,
1322 .enum_list = NULL,
1323 .flags = FLAG_ADVANCED,
1324 },
1325 {
1326 .label = "client NTLMv2 auth",
1327 .type = P_BOOL,
1328 .p_class = P_GLOBAL,
1329 .ptr = &Globals.bClientNTLMv2Auth,
1330 .special = NULL,
1331 .enum_list = NULL,
1332 .flags = FLAG_ADVANCED,
1333 },
1334 {
1335 .label = "client lanman auth",
1336 .type = P_BOOL,
1337 .p_class = P_GLOBAL,
1338 .ptr = &Globals.bClientLanManAuth,
1339 .special = NULL,
1340 .enum_list = NULL,
1341 .flags = FLAG_ADVANCED,
1342 },
1343 {
1344 .label = "client plaintext auth",
1345 .type = P_BOOL,
1346 .p_class = P_GLOBAL,
1347 .ptr = &Globals.bClientPlaintextAuth,
1348 .special = NULL,
1349 .enum_list = NULL,
1350 .flags = FLAG_ADVANCED,
1351 },
1352 {
1353 .label = "username",
1354 .type = P_STRING,
1355 .p_class = P_LOCAL,
1356 .ptr = &sDefault.szUsername,
1357 .special = NULL,
1358 .enum_list = NULL,
1359 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1360 },
1361 {
1362 .label = "user",
1363 .type = P_STRING,
1364 .p_class = P_LOCAL,
1365 .ptr = &sDefault.szUsername,
1366 .special = NULL,
1367 .enum_list = NULL,
1368 .flags = FLAG_HIDE,
1369 },
1370 {
1371 .label = "users",
1372 .type = P_STRING,
1373 .p_class = P_LOCAL,
1374 .ptr = &sDefault.szUsername,
1375 .special = NULL,
1376 .enum_list = NULL,
1377 .flags = FLAG_HIDE,
1378 },
1379 {
1380 .label = "invalid users",
1381 .type = P_LIST,
1382 .p_class = P_LOCAL,
1383 .ptr = &sDefault.szInvalidUsers,
1384 .special = NULL,
1385 .enum_list = NULL,
1386 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1387 },
1388 {
1389 .label = "valid users",
1390 .type = P_LIST,
1391 .p_class = P_LOCAL,
1392 .ptr = &sDefault.szValidUsers,
1393 .special = NULL,
1394 .enum_list = NULL,
1395 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1396 },
1397 {
1398 .label = "admin users",
1399 .type = P_LIST,
1400 .p_class = P_LOCAL,
1401 .ptr = &sDefault.szAdminUsers,
1402 .special = NULL,
1403 .enum_list = NULL,
1404 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1405 },
1406 {
1407 .label = "read list",
1408 .type = P_LIST,
1409 .p_class = P_LOCAL,
1410 .ptr = &sDefault.readlist,
1411 .special = NULL,
1412 .enum_list = NULL,
1413 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1414 },
1415 {
1416 .label = "write list",
1417 .type = P_LIST,
1418 .p_class = P_LOCAL,
1419 .ptr = &sDefault.writelist,
1420 .special = NULL,
1421 .enum_list = NULL,
1422 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1423 },
1424 {
1425 .label = "printer admin",
1426 .type = P_LIST,
1427 .p_class = P_LOCAL,
1428 .ptr = &sDefault.printer_admin,
1429 .special = NULL,
1430 .enum_list = NULL,
1431 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_PRINT | FLAG_DEPRECATED,
1432 },
1433 {
1434 .label = "force user",
1435 .type = P_STRING,
1436 .p_class = P_LOCAL,
1437 .ptr = &sDefault.force_user,
1438 .special = NULL,
1439 .enum_list = NULL,
1440 .flags = FLAG_ADVANCED | FLAG_SHARE,
1441 },
1442 {
1443 .label = "force group",
1444 .type = P_STRING,
1445 .p_class = P_LOCAL,
1446 .ptr = &sDefault.force_group,
1447 .special = NULL,
1448 .enum_list = NULL,
1449 .flags = FLAG_ADVANCED | FLAG_SHARE,
1450 },
1451 {
1452 .label = "group",
1453 .type = P_STRING,
1454 .p_class = P_LOCAL,
1455 .ptr = &sDefault.force_group,
1456 .special = NULL,
1457 .enum_list = NULL,
1458 .flags = FLAG_ADVANCED,
1459 },
1460 {
1461 .label = "read only",
1462 .type = P_BOOL,
1463 .p_class = P_LOCAL,
1464 .ptr = &sDefault.bRead_only,
1465 .special = NULL,
1466 .enum_list = NULL,
1467 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE,
1468 },
1469 {
1470 .label = "write ok",
1471 .type = P_BOOLREV,
1472 .p_class = P_LOCAL,
1473 .ptr = &sDefault.bRead_only,
1474 .special = NULL,
1475 .enum_list = NULL,
1476 .flags = FLAG_HIDE,
1477 },
1478 {
1479 .label = "writeable",
1480 .type = P_BOOLREV,
1481 .p_class = P_LOCAL,
1482 .ptr = &sDefault.bRead_only,
1483 .special = NULL,
1484 .enum_list = NULL,
1485 .flags = FLAG_HIDE,
1486 },
1487 {
1488 .label = "writable",
1489 .type = P_BOOLREV,
1490 .p_class = P_LOCAL,
1491 .ptr = &sDefault.bRead_only,
1492 .special = NULL,
1493 .enum_list = NULL,
1494 .flags = FLAG_HIDE,
1495 },
1496 {
1497 .label = "acl check permissions",
1498 .type = P_BOOL,
1499 .p_class = P_LOCAL,
1500 .ptr = &sDefault.bAclCheckPermissions,
1501 .special = NULL,
1502 .enum_list = NULL,
1503 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1504 },
1505 {
1506 .label = "acl group control",
1507 .type = P_BOOL,
1508 .p_class = P_LOCAL,
1509 .ptr = &sDefault.bAclGroupControl,
1510 .special = NULL,
1511 .enum_list = NULL,
1512 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1513 },
1514 {
1515 .label = "acl map full control",
1516 .type = P_BOOL,
1517 .p_class = P_LOCAL,
1518 .ptr = &sDefault.bAclMapFullControl,
1519 .special = NULL,
1520 .enum_list = NULL,
1521 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1522 },
1523 {
1524 .label = "create mask",
1525 .type = P_OCTAL,
1526 .p_class = P_LOCAL,
1527 .ptr = &sDefault.iCreate_mask,
1528 .special = NULL,
1529 .enum_list = NULL,
1530 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1531 },
1532 {
1533 .label = "create mode",
1534 .type = P_OCTAL,
1535 .p_class = P_LOCAL,
1536 .ptr = &sDefault.iCreate_mask,
1537 .special = NULL,
1538 .enum_list = NULL,
1539 .flags = FLAG_HIDE,
1540 },
1541 {
1542 .label = "force create mode",
1543 .type = P_OCTAL,
1544 .p_class = P_LOCAL,
1545 .ptr = &sDefault.iCreate_force_mode,
1546 .special = NULL,
1547 .enum_list = NULL,
1548 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1549 },
1550 {
1551 .label = "security mask",
1552 .type = P_OCTAL,
1553 .p_class = P_LOCAL,
1554 .ptr = &sDefault.iSecurity_mask,
1555 .special = NULL,
1556 .enum_list = NULL,
1557 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1558 },
1559 {
1560 .label = "force security mode",
1561 .type = P_OCTAL,
1562 .p_class = P_LOCAL,
1563 .ptr = &sDefault.iSecurity_force_mode,
1564 .special = NULL,
1565 .enum_list = NULL,
1566 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1567 },
1568 {
1569 .label = "directory mask",
1570 .type = P_OCTAL,
1571 .p_class = P_LOCAL,
1572 .ptr = &sDefault.iDir_mask,
1573 .special = NULL,
1574 .enum_list = NULL,
1575 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1576 },
1577 {
1578 .label = "directory mode",
1579 .type = P_OCTAL,
1580 .p_class = P_LOCAL,
1581 .ptr = &sDefault.iDir_mask,
1582 .special = NULL,
1583 .enum_list = NULL,
1584 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1585 },
1586 {
1587 .label = "force directory mode",
1588 .type = P_OCTAL,
1589 .p_class = P_LOCAL,
1590 .ptr = &sDefault.iDir_force_mode,
1591 .special = NULL,
1592 .enum_list = NULL,
1593 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1594 },
1595 {
1596 .label = "directory security mask",
1597 .type = P_OCTAL,
1598 .p_class = P_LOCAL,
1599 .ptr = &sDefault.iDir_Security_mask,
1600 .special = NULL,
1601 .enum_list = NULL,
1602 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1603 },
1604 {
1605 .label = "force directory security mode",
1606 .type = P_OCTAL,
1607 .p_class = P_LOCAL,
1608 .ptr = &sDefault.iDir_Security_force_mode,
1609 .special = NULL,
1610 .enum_list = NULL,
1611 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1612 },
1613 {
1614 .label = "force unknown acl user",
1615 .type = P_BOOL,
1616 .p_class = P_LOCAL,
1617 .ptr = &sDefault.bForceUnknownAclUser,
1618 .special = NULL,
1619 .enum_list = NULL,
1620 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1621 },
1622 {
1623 .label = "inherit permissions",
1624 .type = P_BOOL,
1625 .p_class = P_LOCAL,
1626 .ptr = &sDefault.bInheritPerms,
1627 .special = NULL,
1628 .enum_list = NULL,
1629 .flags = FLAG_ADVANCED | FLAG_SHARE,
1630 },
1631 {
1632 .label = "inherit acls",
1633 .type = P_BOOL,
1634 .p_class = P_LOCAL,
1635 .ptr = &sDefault.bInheritACLS,
1636 .special = NULL,
1637 .enum_list = NULL,
1638 .flags = FLAG_ADVANCED | FLAG_SHARE,
1639 },
1640 {
1641 .label = "inherit owner",
1642 .type = P_BOOL,
1643 .p_class = P_LOCAL,
1644 .ptr = &sDefault.bInheritOwner,
1645 .special = NULL,
1646 .enum_list = NULL,
1647 .flags = FLAG_ADVANCED | FLAG_SHARE,
1648 },
1649 {
1650 .label = "guest only",
1651 .type = P_BOOL,
1652 .p_class = P_LOCAL,
1653 .ptr = &sDefault.bGuest_only,
1654 .special = NULL,
1655 .enum_list = NULL,
1656 .flags = FLAG_ADVANCED | FLAG_SHARE,
1657 },
1658 {
1659 .label = "only guest",
1660 .type = P_BOOL,
1661 .p_class = P_LOCAL,
1662 .ptr = &sDefault.bGuest_only,
1663 .special = NULL,
1664 .enum_list = NULL,
1665 .flags = FLAG_HIDE,
1666 },
1667 {
1668 .label = "administrative share",
1669 .type = P_BOOL,
1670 .p_class = P_LOCAL,
1671 .ptr = &sDefault.bAdministrative_share,
1672 .special = NULL,
1673 .enum_list = NULL,
1674 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1675 },
1676
1677 {
1678 .label = "guest ok",
1679 .type = P_BOOL,
1680 .p_class = P_LOCAL,
1681 .ptr = &sDefault.bGuest_ok,
1682 .special = NULL,
1683 .enum_list = NULL,
1684 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1685 },
1686 {
1687 .label = "public",
1688 .type = P_BOOL,
1689 .p_class = P_LOCAL,
1690 .ptr = &sDefault.bGuest_ok,
1691 .special = NULL,
1692 .enum_list = NULL,
1693 .flags = FLAG_HIDE,
1694 },
1695 {
1696 .label = "only user",
1697 .type = P_BOOL,
1698 .p_class = P_LOCAL,
1699 .ptr = &sDefault.bOnlyUser,
1700 .special = NULL,
1701 .enum_list = NULL,
1702 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
1703 },
1704 {
1705 .label = "hosts allow",
1706 .type = P_LIST,
1707 .p_class = P_LOCAL,
1708 .ptr = &sDefault.szHostsallow,
1709 .special = NULL,
1710 .enum_list = NULL,
1711 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1712 },
1713 {
1714 .label = "allow hosts",
1715 .type = P_LIST,
1716 .p_class = P_LOCAL,
1717 .ptr = &sDefault.szHostsallow,
1718 .special = NULL,
1719 .enum_list = NULL,
1720 .flags = FLAG_HIDE,
1721 },
1722 {
1723 .label = "hosts deny",
1724 .type = P_LIST,
1725 .p_class = P_LOCAL,
1726 .ptr = &sDefault.szHostsdeny,
1727 .special = NULL,
1728 .enum_list = NULL,
1729 .flags = FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1730 },
1731 {
1732 .label = "deny hosts",
1733 .type = P_LIST,
1734 .p_class = P_LOCAL,
1735 .ptr = &sDefault.szHostsdeny,
1736 .special = NULL,
1737 .enum_list = NULL,
1738 .flags = FLAG_HIDE,
1739 },
1740 {
1741 .label = "preload modules",
1742 .type = P_LIST,
1743 .p_class = P_GLOBAL,
1744 .ptr = &Globals.szPreloadModules,
1745 .special = NULL,
1746 .enum_list = NULL,
1747 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1748 },
1749 {
1750 .label = "use kerberos keytab",
1751 .type = P_BOOL,
1752 .p_class = P_GLOBAL,
1753 .ptr = &Globals.bUseKerberosKeytab,
1754 .special = NULL,
1755 .enum_list = NULL,
1756 .flags = FLAG_ADVANCED,
1757 },
1758
1759 {N_("Logging Options"), P_SEP, P_SEPARATOR},
1760
1761 {
1762 .label = "log level",
1763 .type = P_STRING,
1764 .p_class = P_GLOBAL,
1765 .ptr = &Globals.szLogLevel,
1766 .special = handle_debug_list,
1767 .enum_list = NULL,
1768 .flags = FLAG_ADVANCED,
1769 },
1770 {
1771 .label = "debuglevel",
1772 .type = P_STRING,
1773 .p_class = P_GLOBAL,
1774 .ptr = &Globals.szLogLevel,
1775 .special = handle_debug_list,
1776 .enum_list = NULL,
1777 .flags = FLAG_HIDE,
1778 },
1779 {
1780 .label = "syslog",
1781 .type = P_INTEGER,
1782 .p_class = P_GLOBAL,
1783 .ptr = &Globals.syslog,
1784 .special = NULL,
1785 .enum_list = NULL,
1786 .flags = FLAG_ADVANCED,
1787 },
1788 {
1789 .label = "syslog only",
1790 .type = P_BOOL,
1791 .p_class = P_GLOBAL,
1792 .ptr = &Globals.bSyslogOnly,
1793 .special = NULL,
1794 .enum_list = NULL,
1795 .flags = FLAG_ADVANCED,
1796 },
1797 {
1798 .label = "log file",
1799 .type = P_STRING,
1800 .p_class = P_GLOBAL,
1801 .ptr = &Globals.szLogFile,
1802 .special = NULL,
1803 .enum_list = NULL,
1804 .flags = FLAG_ADVANCED,
1805 },
1806 {
1807 .label = "max log size",
1808 .type = P_INTEGER,
1809 .p_class = P_GLOBAL,
1810 .ptr = &Globals.max_log_size,
1811 .special = NULL,
1812 .enum_list = NULL,
1813 .flags = FLAG_ADVANCED,
1814 },
1815 {
1816 .label = "debug timestamp",
1817 .type = P_BOOL,
1818 .p_class = P_GLOBAL,
1819 .ptr = &Globals.bTimestampLogs,
1820 .special = NULL,
1821 .enum_list = NULL,
1822 .flags = FLAG_ADVANCED,
1823 },
1824 {
1825 .label = "timestamp logs",
1826 .type = P_BOOL,
1827 .p_class = P_GLOBAL,
1828 .ptr = &Globals.bTimestampLogs,
1829 .special = NULL,
1830 .enum_list = NULL,
1831 .flags = FLAG_ADVANCED,
1832 },
1833 {
1834 .label = "debug prefix timestamp",
1835 .type = P_BOOL,
1836 .p_class = P_GLOBAL,
1837 .ptr = &Globals.bDebugPrefixTimestamp,
1838 .special = NULL,
1839 .enum_list = NULL,
1840 .flags = FLAG_ADVANCED,
1841 },
1842 {
1843 .label = "debug hires timestamp",
1844 .type = P_BOOL,
1845 .p_class = P_GLOBAL,
1846 .ptr = &Globals.bDebugHiresTimestamp,
1847 .special = NULL,
1848 .enum_list = NULL,
1849 .flags = FLAG_ADVANCED,
1850 },
1851 {
1852 .label = "debug pid",
1853 .type = P_BOOL,
1854 .p_class = P_GLOBAL,
1855 .ptr = &Globals.bDebugPid,
1856 .special = NULL,
1857 .enum_list = NULL,
1858 .flags = FLAG_ADVANCED,
1859 },
1860 {
1861 .label = "debug uid",
1862 .type = P_BOOL,
1863 .p_class = P_GLOBAL,
1864 .ptr = &Globals.bDebugUid,
1865 .special = NULL,
1866 .enum_list = NULL,
1867 .flags = FLAG_ADVANCED,
1868 },
1869 {
1870 .label = "debug class",
1871 .type = P_BOOL,
1872 .p_class = P_GLOBAL,
1873 .ptr = &Globals.bDebugClass,
1874 .special = NULL,
1875 .enum_list = NULL,
1876 .flags = FLAG_ADVANCED,
1877 },
1878 {
1879 .label = "enable core files",
1880 .type = P_BOOL,
1881 .p_class = P_GLOBAL,
1882 .ptr = &Globals.bEnableCoreFiles,
1883 .special = NULL,
1884 .enum_list = NULL,
1885 .flags = FLAG_ADVANCED,
1886 },
1887
1888 {N_("Protocol Options"), P_SEP, P_SEPARATOR},
1889
1890 {
1891 .label = "allocation roundup size",
1892 .type = P_INTEGER,
1893 .p_class = P_LOCAL,
1894 .ptr = &sDefault.iallocation_roundup_size,
1895 .special = NULL,
1896 .enum_list = NULL,
1897 .flags = FLAG_ADVANCED,
1898 },
1899 {
1900 .label = "aio read size",
1901 .type = P_INTEGER,
1902 .p_class = P_LOCAL,
1903 .ptr = &sDefault.iAioReadSize,
1904 .special = NULL,
1905 .enum_list = NULL,
1906 .flags = FLAG_ADVANCED,
1907 },
1908 {
1909 .label = "aio write size",
1910 .type = P_INTEGER,
1911 .p_class = P_LOCAL,
1912 .ptr = &sDefault.iAioWriteSize,
1913 .special = NULL,
1914 .enum_list = NULL,
1915 .flags = FLAG_ADVANCED,
1916 },
1917 {
1918 .label = "aio write behind",
1919 .type = P_STRING,
1920 .p_class = P_LOCAL,
1921 .ptr = &sDefault.szAioWriteBehind,
1922 .special = NULL,
1923 .enum_list = NULL,
1924 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1925 },
1926 {
1927 .label = "smb ports",
1928 .type = P_STRING,
1929 .p_class = P_GLOBAL,
1930 .ptr = &Globals.smb_ports,
1931 .special = NULL,
1932 .enum_list = NULL,
1933 .flags = FLAG_ADVANCED,
1934 },
1935 {
1936 .label = "large readwrite",
1937 .type = P_BOOL,
1938 .p_class = P_GLOBAL,
1939 .ptr = &Globals.bLargeReadwrite,
1940 .special = NULL,
1941 .enum_list = NULL,
1942 .flags = FLAG_ADVANCED,
1943 },
1944 {
1945 .label = "max protocol",
1946 .type = P_ENUM,
1947 .p_class = P_GLOBAL,
1948 .ptr = &Globals.maxprotocol,
1949 .special = NULL,
1950 .enum_list = enum_protocol,
1951 .flags = FLAG_ADVANCED,
1952 },
1953 {
1954 .label = "protocol",
1955 .type = P_ENUM,
1956 .p_class = P_GLOBAL,
1957 .ptr = &Globals.maxprotocol,
1958 .special = NULL,
1959 .enum_list = enum_protocol,
1960 .flags = FLAG_ADVANCED,
1961 },
1962 {
1963 .label = "min protocol",
1964 .type = P_ENUM,
1965 .p_class = P_GLOBAL,
1966 .ptr = &Globals.minprotocol,
1967 .special = NULL,
1968 .enum_list = enum_protocol,
1969 .flags = FLAG_ADVANCED,
1970 },
1971 {
1972 .label = "min receivefile size",
1973 .type = P_INTEGER,
1974 .p_class = P_GLOBAL,
1975 .ptr = &Globals.iminreceivefile,
1976 .special = NULL,
1977 .enum_list = NULL,
1978 .flags = FLAG_ADVANCED,
1979 },
1980 {
1981 .label = "read raw",
1982 .type = P_BOOL,
1983 .p_class = P_GLOBAL,
1984 .ptr = &Globals.bReadRaw,
1985 .special = NULL,
1986 .enum_list = NULL,
1987 .flags = FLAG_ADVANCED,
1988 },
1989 {
1990 .label = "write raw",
1991 .type = P_BOOL,
1992 .p_class = P_GLOBAL,
1993 .ptr = &Globals.bWriteRaw,
1994 .special = NULL,
1995 .enum_list = NULL,
1996 .flags = FLAG_ADVANCED,
1997 },
1998 {
1999 .label = "disable netbios",
2000 .type = P_BOOL,
2001 .p_class = P_GLOBAL,
2002 .ptr = &Globals.bDisableNetbios,
2003 .special = NULL,
2004 .enum_list = NULL,
2005 .flags = FLAG_ADVANCED,
2006 },
2007 {
2008 .label = "reset on zero vc",
2009 .type = P_BOOL,
2010 .p_class = P_GLOBAL,
2011 .ptr = &Globals.bResetOnZeroVC,
2012 .special = NULL,
2013 .enum_list = NULL,
2014 .flags = FLAG_ADVANCED,
2015 },
2016 {
2017 .label = "acl compatibility",
2018 .type = P_ENUM,
2019 .p_class = P_GLOBAL,
2020 .ptr = &Globals.iAclCompat,
2021 .special = NULL,
2022 .enum_list = enum_acl_compat_vals,
2023 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2024 },
2025 {
2026 .label = "defer sharing violations",
2027 .type = P_BOOL,
2028 .p_class = P_GLOBAL,
2029 .ptr = &Globals.bDeferSharingViolations,
2030 .special = NULL,
2031 .enum_list = NULL,
2032 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2033 },
2034 {
2035 .label = "ea support",
2036 .type = P_BOOL,
2037 .p_class = P_LOCAL,
2038 .ptr = &sDefault.bEASupport,
2039 .special = NULL,
2040 .enum_list = NULL,
2041 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2042 },
2043 {
2044 .label = "nt acl support",
2045 .type = P_BOOL,
2046 .p_class = P_LOCAL,
2047 .ptr = &sDefault.bNTAclSupport,
2048 .special = NULL,
2049 .enum_list = NULL,
2050 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2051 },
2052 {
2053 .label = "nt pipe support",
2054 .type = P_BOOL,
2055 .p_class = P_GLOBAL,
2056 .ptr = &Globals.bNTPipeSupport,
2057 .special = NULL,
2058 .enum_list = NULL,
2059 .flags = FLAG_ADVANCED,
2060 },
2061 {
2062 .label = "nt status support",
2063 .type = P_BOOL,
2064 .p_class = P_GLOBAL,
2065 .ptr = &Globals.bNTStatusSupport,
2066 .special = NULL,
2067 .enum_list = NULL,
2068 .flags = FLAG_ADVANCED,
2069 },
2070 {
2071 .label = "profile acls",
2072 .type = P_BOOL,
2073 .p_class = P_LOCAL,
2074 .ptr = &sDefault.bProfileAcls,
2075 .special = NULL,
2076 .enum_list = NULL,
2077 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
2078 },
2079 {
2080 .label = "announce version",
2081 .type = P_STRING,
2082 .p_class = P_GLOBAL,
2083 .ptr = &Globals.szAnnounceVersion,
2084 .special = NULL,
2085 .enum_list = NULL,
2086 .flags = FLAG_ADVANCED,
2087 },
2088 {
2089 .label = "announce as",
2090 .type = P_ENUM,
2091 .p_class = P_GLOBAL,
2092 .ptr = &Globals.announce_as,
2093 .special = NULL,
2094 .enum_list = enum_announce_as,
2095 .flags = FLAG_ADVANCED,
2096 },
2097 {
2098 .label = "map acl inherit",
2099 .type = P_BOOL,
2100 .p_class = P_LOCAL,
2101 .ptr = &sDefault.bMap_acl_inherit,
2102 .special = NULL,
2103 .enum_list = NULL,
2104 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2105 },
2106 {
2107 .label = "afs share",
2108 .type = P_BOOL,
2109 .p_class = P_LOCAL,
2110 .ptr = &sDefault.bAfs_Share,
2111 .special = NULL,
2112 .enum_list = NULL,
2113 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2114 },
2115 {
2116 .label = "max mux",
2117 .type = P_INTEGER,
2118 .p_class = P_GLOBAL,
2119 .ptr = &Globals.max_mux,
2120 .special = NULL,
2121 .enum_list = NULL,
2122 .flags = FLAG_ADVANCED,
2123 },
2124 {
2125 .label = "max xmit",
2126 .type = P_INTEGER,
2127 .p_class = P_GLOBAL,
2128 .ptr = &Globals.max_xmit,
2129 .special = NULL,
2130 .enum_list = NULL,
2131 .flags = FLAG_ADVANCED,
2132 },
2133 {
2134 .label = "name resolve order",
2135 .type = P_STRING,
2136 .p_class = P_GLOBAL,
2137 .ptr = &Globals.szNameResolveOrder,
2138 .special = NULL,
2139 .enum_list = NULL,
2140 .flags = FLAG_ADVANCED | FLAG_WIZARD,
2141 },
2142 {
2143 .label = "max ttl",
2144 .type = P_INTEGER,
2145 .p_class = P_GLOBAL,
2146 .ptr = &Globals.max_ttl,
2147 .special = NULL,
2148 .enum_list = NULL,
2149 .flags = FLAG_ADVANCED,
2150 },
2151 {
2152 .label = "max wins ttl",
2153 .type = P_INTEGER,
2154 .p_class = P_GLOBAL,
2155 .ptr = &Globals.max_wins_ttl,
2156 .special = NULL,
2157 .enum_list = NULL,
2158 .flags = FLAG_ADVANCED,
2159 },
2160 {
2161 .label = "min wins ttl",
2162 .type = P_INTEGER,
2163 .p_class = P_GLOBAL,
2164 .ptr = &Globals.min_wins_ttl,
2165 .special = NULL,
2166 .enum_list = NULL,
2167 .flags = FLAG_ADVANCED,
2168 },
2169 {
2170 .label = "time server",
2171 .type = P_BOOL,
2172 .p_class = P_GLOBAL,
2173 .ptr = &Globals.bTimeServer,
2174 .special = NULL,
2175 .enum_list = NULL,
2176 .flags = FLAG_ADVANCED,
2177 },
2178 {
2179 .label = "unix extensions",
2180 .type = P_BOOL,
2181 .p_class = P_GLOBAL,
2182 .ptr = &Globals.bUnixExtensions,
2183 .special = NULL,
2184 .enum_list = NULL,
2185 .flags = FLAG_ADVANCED,
2186 },
2187 {
2188 .label = "use spnego",
2189 .type = P_BOOL,
2190 .p_class = P_GLOBAL,
2191 .ptr = &Globals.bUseSpnego,
2192 .special = NULL,
2193 .enum_list = NULL,
2194 .flags = FLAG_ADVANCED,
2195 },
2196 {
2197 .label = "client signing",
2198 .type = P_ENUM,
2199 .p_class = P_GLOBAL,
2200 .ptr = &Globals.client_signing,
2201 .special = NULL,
2202 .enum_list = enum_smb_signing_vals,
2203 .flags = FLAG_ADVANCED,
2204 },
2205 {
2206 .label = "server signing",
2207 .type = P_ENUM,
2208 .p_class = P_GLOBAL,
2209 .ptr = &Globals.server_signing,
2210 .special = NULL,
2211 .enum_list = enum_smb_signing_vals,
2212 .flags = FLAG_ADVANCED,
2213 },
2214 {
2215 .label = "smb encrypt",
2216 .type = P_ENUM,
2217 .p_class = P_LOCAL,
2218 .ptr = &sDefault.ismb_encrypt,
2219 .special = NULL,
2220 .enum_list = enum_smb_signing_vals,
2221 .flags = FLAG_ADVANCED,
2222 },
2223 {
2224 .label = "client use spnego",
2225 .type = P_BOOL,
2226 .p_class = P_GLOBAL,
2227 .ptr = &Globals.bClientUseSpnego,
2228 .special = NULL,
2229 .enum_list = NULL,
2230 .flags = FLAG_ADVANCED,
2231 },
2232 {
2233 .label = "client ldap sasl wrapping",
2234 .type = P_ENUM,
2235 .p_class = P_GLOBAL,
2236 .ptr = &Globals.client_ldap_sasl_wrapping,
2237 .special = NULL,
2238 .enum_list = enum_ldap_sasl_wrapping,
2239 .flags = FLAG_ADVANCED,
2240 },
2241 {
2242 .label = "enable asu support",
2243 .type = P_BOOL,
2244 .p_class = P_GLOBAL,
2245 .ptr = &Globals.bASUSupport,
2246 .special = NULL,
2247 .enum_list = NULL,
2248 .flags = FLAG_ADVANCED,
2249 },
2250 {
2251 .label = "svcctl list",
2252 .type = P_LIST,
2253 .p_class = P_GLOBAL,
2254 .ptr = &Globals.szServicesList,
2255 .special = NULL,
2256 .enum_list = NULL,
2257 .flags = FLAG_ADVANCED,
2258 },
2259
2260 {N_("Tuning Options"), P_SEP, P_SEPARATOR},
2261
2262 {
2263 .label = "block size",
2264 .type = P_INTEGER,
2265 .p_class = P_LOCAL,
2266 .ptr = &sDefault.iBlock_size,
2267 .special = NULL,
2268 .enum_list = NULL,
2269 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2270 },
2271 {
2272 .label = "deadtime",
2273 .type = P_INTEGER,
2274 .p_class = P_GLOBAL,
2275 .ptr = &Globals.deadtime,
2276 .special = NULL,
2277 .enum_list = NULL,
2278 .flags = FLAG_ADVANCED,
2279 },
2280 {
2281 .label = "getwd cache",
2282 .type = P_BOOL,
2283 .p_class = P_GLOBAL,
2284 .ptr = &Globals.getwd_cache,
2285 .special = NULL,
2286 .enum_list = NULL,
2287 .flags = FLAG_ADVANCED,
2288 },
2289 {
2290 .label = "keepalive",
2291 .type = P_INTEGER,
2292 .p_class = P_GLOBAL,
2293 .ptr = &Globals.iKeepalive,
2294 .special = NULL,
2295 .enum_list = NULL,
2296 .flags = FLAG_ADVANCED,
2297 },
2298 {
2299 .label = "change notify",
2300 .type = P_BOOL,
2301 .p_class = P_LOCAL,
2302 .ptr = &sDefault.bChangeNotify,
2303 .special = NULL,
2304 .enum_list = NULL,
2305 .flags = FLAG_ADVANCED | FLAG_SHARE,
2306 },
2307 {
2308 .label = "directory name cache size",
2309 .type = P_INTEGER,
2310 .p_class = P_LOCAL,
2311 .ptr = &sDefault.iDirectoryNameCacheSize,
2312 .special = NULL,
2313 .enum_list = NULL,
2314 .flags = FLAG_ADVANCED | FLAG_SHARE,
2315 },
2316 {
2317 .label = "kernel change notify",
2318 .type = P_BOOL,
2319 .p_class = P_LOCAL,
2320 .ptr = &sDefault.bKernelChangeNotify,
2321 .special = NULL,
2322 .enum_list = NULL,
2323 .flags = FLAG_ADVANCED | FLAG_SHARE,
2324 },
2325 {
2326 .label = "lpq cache time",
2327 .type = P_INTEGER,
2328 .p_class = P_GLOBAL,
2329 .ptr = &Globals.lpqcachetime,
2330 .special = NULL,
2331 .enum_list = NULL,
2332 .flags = FLAG_ADVANCED,
2333 },
2334 {
2335 .label = "max smbd processes",
2336 .type = P_INTEGER,
2337 .p_class = P_GLOBAL,
2338 .ptr = &Globals.iMaxSmbdProcesses,
2339 .special = NULL,
2340 .enum_list = NULL,
2341 .flags = FLAG_ADVANCED,
2342 },
2343 {
2344 .label = "max connections",
2345 .type = P_INTEGER,
2346 .p_class = P_LOCAL,
2347 .ptr = &sDefault.iMaxConnections,
2348 .special = NULL,
2349 .enum_list = NULL,
2350 .flags = FLAG_ADVANCED | FLAG_SHARE,
2351 },
2352 {
2353 .label = "paranoid server security",
2354 .type = P_BOOL,
2355 .p_class = P_GLOBAL,
2356 .ptr = &Globals.paranoid_server_security,
2357 .special = NULL,
2358 .enum_list = NULL,
2359 .flags = FLAG_ADVANCED,
2360 },
2361 {
2362 .label = "max disk size",
2363 .type = P_INTEGER,
2364 .p_class = P_GLOBAL,
2365 .ptr = &Globals.maxdisksize,
2366 .special = NULL,
2367 .enum_list = NULL,
2368 .flags = FLAG_ADVANCED,
2369 },
2370 {
2371 .label = "max open files",
2372 .type = P_INTEGER,
2373 .p_class = P_GLOBAL,
2374 .ptr = &Globals.max_open_files,
2375 .special = NULL,
2376 .enum_list = NULL,
2377 .flags = FLAG_ADVANCED,
2378 },
2379 {
2380 .label = "min print space",
2381 .type = P_INTEGER,
2382 .p_class = P_LOCAL,
2383 .ptr = &sDefault.iMinPrintSpace,
2384 .special = NULL,
2385 .enum_list = NULL,
2386 .flags = FLAG_ADVANCED | FLAG_PRINT,
2387 },
2388 {
2389 .label = "socket options",
2390 .type = P_STRING,
2391 .p_class = P_GLOBAL,
2392 .ptr = &Globals.szSocketOptions,
2393 .special = NULL,
2394 .enum_list = NULL,
2395 .flags = FLAG_ADVANCED,
2396 },
2397 {
2398 .label = "strict allocate",
2399 .type = P_BOOL,
2400 .p_class = P_LOCAL,
2401 .ptr = &sDefault.bStrictAllocate,
2402 .special = NULL,
2403 .enum_list = NULL,
2404 .flags = FLAG_ADVANCED | FLAG_SHARE,
2405 },
2406 {
2407 .label = "strict sync",
2408 .type = P_BOOL,
2409 .p_class = P_LOCAL,
2410 .ptr = &sDefault.bStrictSync,
2411 .special = NULL,
2412 .enum_list = NULL,
2413 .flags = FLAG_ADVANCED | FLAG_SHARE,
2414 },
2415 {
2416 .label = "sync always",
2417 .type = P_BOOL,
2418 .p_class = P_LOCAL,
2419 .ptr = &sDefault.bSyncAlways,
2420 .special = NULL,
2421 .enum_list = NULL,
2422 .flags = FLAG_ADVANCED | FLAG_SHARE,
2423 },
2424 {
2425 .label = "use mmap",
2426 .type = P_BOOL,
2427 .p_class = P_GLOBAL,
2428 .ptr = &Globals.bUseMmap,
2429 .special = NULL,
2430 .enum_list = NULL,
2431 .flags = FLAG_ADVANCED,
2432 },
2433 {
2434 .label = "use sendfile",
2435 .type = P_BOOL,
2436 .p_class = P_LOCAL,
2437 .ptr = &sDefault.bUseSendfile,
2438 .special = NULL,
2439 .enum_list = NULL,
2440 .flags = FLAG_ADVANCED | FLAG_SHARE,
2441 },
2442 {
2443 .label = "hostname lookups",
2444 .type = P_BOOL,
2445 .p_class = P_GLOBAL,
2446 .ptr = &Globals.bHostnameLookups,
2447 .special = NULL,
2448 .enum_list = NULL,
2449 .flags = FLAG_ADVANCED,
2450 },
2451 {
2452 .label = "write cache size",
2453 .type = P_INTEGER,
2454 .p_class = P_LOCAL,
2455 .ptr = &sDefault.iWriteCacheSize,
2456 .special = NULL,
2457 .enum_list = NULL,
2458 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED,
2459 },
2460 {
2461 .label = "name cache timeout",
2462 .type = P_INTEGER,
2463 .p_class = P_GLOBAL,
2464 .ptr = &Globals.name_cache_timeout,
2465 .special = NULL,
2466 .enum_list = NULL,
2467 .flags = FLAG_ADVANCED,
2468 },
2469 {
2470 .label = "ctdbd socket",
2471 .type = P_STRING,
2472 .p_class = P_GLOBAL,
2473 .ptr = &Globals.ctdbdSocket,
2474 .special = NULL,
2475 .enum_list = NULL,
2476 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2477 },
2478 {
2479 .label = "cluster addresses",
2480 .type = P_LIST,
2481 .p_class = P_GLOBAL,
2482 .ptr = &Globals.szClusterAddresses,
2483 .special = NULL,
2484 .enum_list = NULL,
2485 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2486 },
2487 {
2488 .label = "clustering",
2489 .type = P_BOOL,
2490 .p_class = P_GLOBAL,
2491 .ptr = &Globals.clustering,
2492 .special = NULL,
2493 .enum_list = NULL,
2494 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2495 },
2496
2497 {N_("Printing Options"), P_SEP, P_SEPARATOR},
2498
2499 {
2500 .label = "max reported print jobs",
2501 .type = P_INTEGER,
2502 .p_class = P_LOCAL,
2503 .ptr = &sDefault.iMaxReportedPrintJobs,
2504 .special = NULL,
2505 .enum_list = NULL,
2506 .flags = FLAG_ADVANCED | FLAG_PRINT,
2507 },
2508 {
2509 .label = "max print jobs",
2510 .type = P_INTEGER,
2511 .p_class = P_LOCAL,
2512 .ptr = &sDefault.iMaxPrintJobs,
2513 .special = NULL,
2514 .enum_list = NULL,
2515 .flags = FLAG_ADVANCED | FLAG_PRINT,
2516 },
2517 {
2518 .label = "load printers",
2519 .type = P_BOOL,
2520 .p_class = P_GLOBAL,
2521 .ptr = &Globals.bLoadPrinters,
2522 .special = NULL,
2523 .enum_list = NULL,
2524 .flags = FLAG_ADVANCED | FLAG_PRINT,
2525 },
2526 {
2527 .label = "printcap cache time",
2528 .type = P_INTEGER,
2529 .p_class = P_GLOBAL,
2530 .ptr = &Globals.PrintcapCacheTime,
2531 .special = NULL,
2532 .enum_list = NULL,
2533 .flags = FLAG_ADVANCED | FLAG_PRINT,
2534 },
2535 {
2536 .label = "printcap name",
2537 .type = P_STRING,
2538 .p_class = P_GLOBAL,
2539 .ptr = &Globals.szPrintcapname,
2540 .special = NULL,
2541 .enum_list = NULL,
2542 .flags = FLAG_ADVANCED | FLAG_PRINT,
2543 },
2544 {
2545 .label = "printcap",
2546 .type = P_STRING,
2547 .p_class = P_GLOBAL,
2548 .ptr = &Globals.szPrintcapname,
2549 .special = NULL,
2550 .enum_list = NULL,
2551 .flags = FLAG_HIDE,
2552 },
2553 {
2554 .label = "printable",
2555 .type = P_BOOL,
2556 .p_class = P_LOCAL,
2557 .ptr = &sDefault.bPrint_ok,
2558 .special = NULL,
2559 .enum_list = NULL,
2560 .flags = FLAG_ADVANCED | FLAG_PRINT,
2561 },
2562 {
2563 .label = "print ok",
2564 .type = P_BOOL,
2565 .p_class = P_LOCAL,
2566 .ptr = &sDefault.bPrint_ok,
2567 .special = NULL,
2568 .enum_list = NULL,
2569 .flags = FLAG_HIDE,
2570 },
2571 {
2572 .label = "printing",
2573 .type = P_ENUM,
2574 .p_class = P_LOCAL,
2575 .ptr = &sDefault.iPrinting,
2576 .special = handle_printing,
2577 .enum_list = enum_printing,
2578 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2579 },
2580 {
2581 .label = "cups options",
2582 .type = P_STRING,
2583 .p_class = P_LOCAL,
2584 .ptr = &sDefault.szCupsOptions,
2585 .special = NULL,
2586 .enum_list = NULL,
2587 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2588 },
2589 {
2590 .label = "cups server",
2591 .type = P_STRING,
2592 .p_class = P_GLOBAL,
2593 .ptr = &Globals.szCupsServer,
2594 .special = NULL,
2595 .enum_list = NULL,
2596 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2597 },
2598 {
2599 .label = "cups connection timeout",
2600 .type = P_INTEGER,
2601 .p_class = P_GLOBAL,
2602 .ptr = &Globals.cups_connection_timeout,
2603 .special = NULL,
2604 .enum_list = NULL,
2605 .flags = FLAG_ADVANCED,
2606 },
2607 {
2608 .label = "iprint server",
2609 .type = P_STRING,
2610 .p_class = P_GLOBAL,
2611 .ptr = &Globals.szIPrintServer,
2612 .special = NULL,
2613 .enum_list = NULL,
2614 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2615 },
2616 {
2617 .label = "print command",
2618 .type = P_STRING,
2619 .p_class = P_LOCAL,
2620 .ptr = &sDefault.szPrintcommand,
2621 .special = NULL,
2622 .enum_list = NULL,
2623 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2624 },
2625 {
2626 .label = "disable spoolss",
2627 .type = P_BOOL,
2628 .p_class = P_GLOBAL,
2629 .ptr = &Globals.bDisableSpoolss,
2630 .special = NULL,
2631 .enum_list = NULL,
2632 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2633 },
2634 {
2635 .label = "enable spoolss",
2636 .type = P_BOOLREV,
2637 .p_class = P_GLOBAL,
2638 .ptr = &Globals.bDisableSpoolss,
2639 .special = NULL,
2640 .enum_list = NULL,
2641 .flags = FLAG_HIDE,
2642 },
2643 {
2644 .label = "lpq command",
2645 .type = P_STRING,
2646 .p_class = P_LOCAL,
2647 .ptr = &sDefault.szLpqcommand,
2648 .special = NULL,
2649 .enum_list = NULL,
2650 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2651 },
2652 {
2653 .label = "lprm command",
2654 .type = P_STRING,
2655 .p_class = P_LOCAL,
2656 .ptr = &sDefault.szLprmcommand,
2657 .special = NULL,
2658 .enum_list = NULL,
2659 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2660 },
2661 {
2662 .label = "lppause command",
2663 .type = P_STRING,
2664 .p_class = P_LOCAL,
2665 .ptr = &sDefault.szLppausecommand,
2666 .special = NULL,
2667 .enum_list = NULL,
2668 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2669 },
2670 {
2671 .label = "lpresume command",
2672 .type = P_STRING,
2673 .p_class = P_LOCAL,
2674 .ptr = &sDefault.szLpresumecommand,
2675 .special = NULL,
2676 .enum_list = NULL,
2677 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2678 },
2679 {
2680 .label = "queuepause command",
2681 .type = P_STRING,
2682 .p_class = P_LOCAL,
2683 .ptr = &sDefault.szQueuepausecommand,
2684 .special = NULL,
2685 .enum_list = NULL,
2686 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2687 },
2688 {
2689 .label = "queueresume command",
2690 .type = P_STRING,
2691 .p_class = P_LOCAL,
2692 .ptr = &sDefault.szQueueresumecommand,
2693 .special = NULL,
2694 .enum_list = NULL,
2695 .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
2696 },
2697 {
2698 .label = "addport command",
2699 .type = P_STRING,
2700 .p_class = P_GLOBAL,
2701 .ptr = &Globals.szAddPortCommand,
2702 .special = NULL,
2703 .enum_list = NULL,
2704 .flags = FLAG_ADVANCED,
2705 },
2706 {
2707 .label = "enumports command",
2708 .type = P_STRING,
2709 .p_class = P_GLOBAL,
2710 .ptr = &Globals.szEnumPortsCommand,
2711 .special = NULL,
2712 .enum_list = NULL,
2713 .flags = FLAG_ADVANCED,
2714 },
2715 {
2716 .label = "addprinter command",
2717 .type = P_STRING,
2718 .p_class = P_GLOBAL,
2719 .ptr = &Globals.szAddPrinterCommand,
2720 .special = NULL,
2721 .enum_list = NULL,
2722 .flags = FLAG_ADVANCED,
2723 },
2724 {
2725 .label = "deleteprinter command",
2726 .type = P_STRING,
2727 .p_class = P_GLOBAL,
2728 .ptr = &Globals.szDeletePrinterCommand,
2729 .special = NULL,
2730 .enum_list = NULL,
2731 .flags = FLAG_ADVANCED,
2732 },
2733 {
2734 .label = "show add printer wizard",
2735 .type = P_BOOL,
2736 .p_class = P_GLOBAL,
2737 .ptr = &Globals.bMsAddPrinterWizard,
2738 .special = NULL,
2739 .enum_list = NULL,
2740 .flags = FLAG_ADVANCED,
2741 },
2742 {
2743 .label = "os2 driver map",
2744 .type = P_STRING,
2745 .p_class = P_GLOBAL,
2746 .ptr = &Globals.szOs2DriverMap,
2747 .special = NULL,
2748 .enum_list = NULL,
2749 .flags = FLAG_ADVANCED,
2750 },
2751
2752 {
2753 .label = "printer name",
2754 .type = P_STRING,
2755 .p_class = P_LOCAL,
2756 .ptr = &sDefault.szPrintername,
2757 .special = NULL,
2758 .enum_list = NULL,
2759 .flags = FLAG_ADVANCED | FLAG_PRINT,
2760 },
2761 {
2762 .label = "printer",
2763 .type = P_STRING,
2764 .p_class = P_LOCAL,
2765 .ptr = &sDefault.szPrintername,
2766 .special = NULL,
2767 .enum_list = NULL,
2768 .flags = FLAG_HIDE,
2769 },
2770 {
2771 .label = "use client driver",
2772 .type = P_BOOL,
2773 .p_class = P_LOCAL,
2774 .ptr = &sDefault.bUseClientDriver,
2775 .special = NULL,
2776 .enum_list = NULL,
2777 .flags = FLAG_ADVANCED | FLAG_PRINT,
2778 },
2779 {
2780 .label = "default devmode",
2781 .type = P_BOOL,
2782 .p_class = P_LOCAL,
2783 .ptr = &sDefault.bDefaultDevmode,
2784 .special = NULL,
2785 .enum_list = NULL,
2786 .flags = FLAG_ADVANCED | FLAG_PRINT,
2787 },
2788 {
2789 .label = "force printername",
2790 .type = P_BOOL,
2791 .p_class = P_LOCAL,
2792 .ptr = &sDefault.bForcePrintername,
2793 .special = NULL,
2794 .enum_list = NULL,
2795 .flags = FLAG_ADVANCED | FLAG_PRINT,
2796 },
2797 {
2798 .label = "printjob username",
2799 .type = P_STRING,
2800 .p_class = P_LOCAL,
2801 .ptr = &sDefault.szPrintjobUsername,
2802 .special = NULL,
2803 .enum_list = NULL,
2804 .flags = FLAG_ADVANCED | FLAG_PRINT,
2805 },
2806
2807 {N_("Filename Handling"), P_SEP, P_SEPARATOR},
2808
2809 {
2810 .label = "mangling method",
2811 .type = P_STRING,
2812 .p_class = P_GLOBAL,
2813 .ptr = &Globals.szManglingMethod,
2814 .special = NULL,
2815 .enum_list = NULL,
2816 .flags = FLAG_ADVANCED,
2817 },
2818 {
2819 .label = "mangle prefix",
2820 .type = P_INTEGER,
2821 .p_class = P_GLOBAL,
2822 .ptr = &Globals.mangle_prefix,
2823 .special = NULL,
2824 .enum_list = NULL,
2825 .flags = FLAG_ADVANCED,
2826 },
2827
2828 {
2829 .label = "default case",
2830 .type = P_ENUM,
2831 .p_class = P_LOCAL,
2832 .ptr = &sDefault.iDefaultCase,
2833 .special = NULL,
2834 .enum_list = enum_case,
2835 .flags = FLAG_ADVANCED | FLAG_SHARE,
2836 },
2837 {
2838 .label = "case sensitive",
2839 .type = P_ENUM,
2840 .p_class = P_LOCAL,
2841 .ptr = &sDefault.iCaseSensitive,
2842 .special = NULL,
2843 .enum_list = enum_bool_auto,
2844 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2845 },
2846 {
2847 .label = "casesignames",
2848 .type = P_ENUM,
2849 .p_class = P_LOCAL,
2850 .ptr = &sDefault.iCaseSensitive,
2851 .special = NULL,
2852 .enum_list = enum_bool_auto,
2853 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_HIDE,
2854 },
2855 {
2856 .label = "preserve case",
2857 .type = P_BOOL,
2858 .p_class = P_LOCAL,
2859 .ptr = &sDefault.bCasePreserve,
2860 .special = NULL,
2861 .enum_list = NULL,
2862 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2863 },
2864 {
2865 .label = "short preserve case",
2866 .type = P_BOOL,
2867 .p_class = P_LOCAL,
2868 .ptr = &sDefault.bShortCasePreserve,
2869 .special = NULL,
2870 .enum_list = NULL,
2871 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2872 },
2873 {
2874 .label = "mangling char",
2875 .type = P_CHAR,
2876 .p_class = P_LOCAL,
2877 .ptr = &sDefault.magic_char,
2878 .special = NULL,
2879 .enum_list = NULL,
2880 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2881 },
2882 {
2883 .label = "hide dot files",
2884 .type = P_BOOL,
2885 .p_class = P_LOCAL,
2886 .ptr = &sDefault.bHideDotFiles,
2887 .special = NULL,
2888 .enum_list = NULL,
2889 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2890 },
2891 {
2892 .label = "hide special files",
2893 .type = P_BOOL,
2894 .p_class = P_LOCAL,
2895 .ptr = &sDefault.bHideSpecialFiles,
2896 .special = NULL,
2897 .enum_list = NULL,
2898 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2899 },
2900 {
2901 .label = "hide unreadable",
2902 .type = P_BOOL,
2903 .p_class = P_LOCAL,
2904 .ptr = &sDefault.bHideUnReadable,
2905 .special = NULL,
2906 .enum_list = NULL,
2907 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2908 },
2909 {
2910 .label = "hide unwriteable files",
2911 .type = P_BOOL,
2912 .p_class = P_LOCAL,
2913 .ptr = &sDefault.bHideUnWriteableFiles,
2914 .special = NULL,
2915 .enum_list = NULL,
2916 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2917 },
2918 {
2919 .label = "delete veto files",
2920 .type = P_BOOL,
2921 .p_class = P_LOCAL,
2922 .ptr = &sDefault.bDeleteVetoFiles,
2923 .special = NULL,
2924 .enum_list = NULL,
2925 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2926 },
2927 {
2928 .label = "veto files",
2929 .type = P_STRING,
2930 .p_class = P_LOCAL,
2931 .ptr = &sDefault.szVetoFiles,
2932 .special = NULL,
2933 .enum_list = NULL,
2934 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2935 },
2936 {
2937 .label = "hide files",
2938 .type = P_STRING,
2939 .p_class = P_LOCAL,
2940 .ptr = &sDefault.szHideFiles,
2941 .special = NULL,
2942 .enum_list = NULL,
2943 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2944 },
2945 {
2946 .label = "veto oplock files",
2947 .type = P_STRING,
2948 .p_class = P_LOCAL,
2949 .ptr = &sDefault.szVetoOplockFiles,
2950 .special = NULL,
2951 .enum_list = NULL,
2952 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2953 },
2954 {
2955 .label = "map archive",
2956 .type = P_BOOL,
2957 .p_class = P_LOCAL,
2958 .ptr = &sDefault.bMap_archive,
2959 .special = NULL,
2960 .enum_list = NULL,
2961 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2962 },
2963 {
2964 .label = "map hidden",
2965 .type = P_BOOL,
2966 .p_class = P_LOCAL,
2967 .ptr = &sDefault.bMap_hidden,
2968 .special = NULL,
2969 .enum_list = NULL,
2970 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2971 },
2972 {
2973 .label = "map system",
2974 .type = P_BOOL,
2975 .p_class = P_LOCAL,
2976 .ptr = &sDefault.bMap_system,
2977 .special = NULL,
2978 .enum_list = NULL,
2979 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2980 },
2981 {
2982 .label = "map readonly",
2983 .type = P_ENUM,
2984 .p_class = P_LOCAL,
2985 .ptr = &sDefault.iMap_readonly,
2986 .special = NULL,
2987 .enum_list = enum_map_readonly,
2988 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2989 },
2990 {
2991 .label = "mangled names",
2992 .type = P_BOOL,
2993 .p_class = P_LOCAL,
2994 .ptr = &sDefault.bMangledNames,
2995 .special = NULL,
2996 .enum_list = NULL,
2997 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
2998 },
2999 {
3000 .label = "max stat cache size",
3001 .type = P_INTEGER,
3002 .p_class = P_GLOBAL,
3003 .ptr = &Globals.iMaxStatCacheSize,
3004 .special = NULL,
3005 .enum_list = NULL,
3006 .flags = FLAG_ADVANCED,
3007 },
3008 {
3009 .label = "stat cache",
3010 .type = P_BOOL,
3011 .p_class = P_GLOBAL,
3012 .ptr = &Globals.bStatCache,
3013 .special = NULL,
3014 .enum_list = NULL,
3015 .flags = FLAG_ADVANCED,
3016 },
3017 {
3018 .label = "store dos attributes",
3019 .type = P_BOOL,
3020 .p_class = P_LOCAL,
3021 .ptr = &sDefault.bStoreDosAttributes,
3022 .special = NULL,
3023 .enum_list = NULL,
3024 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3025 },
3026 {
3027 .label = "dmapi support",
3028 .type = P_BOOL,
3029 .p_class = P_LOCAL,
3030 .ptr = &sDefault.bDmapiSupport,
3031 .special = NULL,
3032 .enum_list = NULL,
3033 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3034 },
3035
3036
3037 {N_("Domain Options"), P_SEP, P_SEPARATOR},
3038
3039 {
3040 .label = "machine password timeout",
3041 .type = P_INTEGER,
3042 .p_class = P_GLOBAL,
3043 .ptr = &Globals.machine_password_timeout,
3044 .special = NULL,
3045 .enum_list = NULL,
3046 .flags = FLAG_ADVANCED | FLAG_WIZARD,
3047 },
3048
3049 {N_("Logon Options"), P_SEP, P_SEPARATOR},
3050
3051 {
3052 .label = "add user script",
3053 .type = P_STRING,
3054 .p_class = P_GLOBAL,
3055 .ptr = &Globals.szAddUserScript,
3056 .special = NULL,
3057 .enum_list = NULL,
3058 .flags = FLAG_ADVANCED,
3059 },
3060 {
3061 .label = "rename user script",
3062 .type = P_STRING,
3063 .p_class = P_GLOBAL,
3064 .ptr = &Globals.szRenameUserScript,
3065 .special = NULL,
3066 .enum_list = NULL,
3067 .flags = FLAG_ADVANCED,
3068 },
3069 {
3070 .label = "delete user script",
3071 .type = P_STRING,
3072 .p_class = P_GLOBAL,
3073 .ptr = &Globals.szDelUserScript,
3074 .special = NULL,
3075 .enum_list = NULL,
3076 .flags = FLAG_ADVANCED,
3077 },
3078 {
3079 .label = "add group script",
3080 .type = P_STRING,
3081 .p_class = P_GLOBAL,
3082 .ptr = &Globals.szAddGroupScript,
3083 .special = NULL,
3084 .enum_list = NULL,
3085 .flags = FLAG_ADVANCED,
3086 },
3087 {
3088 .label = "delete group script",
3089 .type = P_STRING,
3090 .p_class = P_GLOBAL,
3091 .ptr = &Globals.szDelGroupScript,
3092 .special = NULL,
3093 .enum_list = NULL,
3094 .flags = FLAG_ADVANCED,
3095 },
3096 {
3097 .label = "add user to group script",
3098 .type = P_STRING,
3099 .p_class = P_GLOBAL,
3100 .ptr = &Globals.szAddUserToGroupScript,
3101 .special = NULL,
3102 .enum_list = NULL,
3103 .flags = FLAG_ADVANCED,
3104 },
3105 {
3106 .label = "delete user from group script",
3107 .type = P_STRING,
3108 .p_class = P_GLOBAL,
3109 .ptr = &Globals.szDelUserFromGroupScript,
3110 .special = NULL,
3111 .enum_list = NULL,
3112 .flags = FLAG_ADVANCED,
3113 },
3114 {
3115 .label = "set primary group script",
3116 .type = P_STRING,
3117 .p_class = P_GLOBAL,
3118 .ptr = &Globals.szSetPrimaryGroupScript,
3119 .special = NULL,
3120 .enum_list = NULL,
3121 .flags = FLAG_ADVANCED,
3122 },
3123 {
3124 .label = "add machine script",
3125 .type = P_STRING,
3126 .p_class = P_GLOBAL,
3127 .ptr = &Globals.szAddMachineScript,
3128 .special = NULL,
3129 .enum_list = NULL,
3130 .flags = FLAG_ADVANCED,
3131 },
3132 {
3133 .label = "shutdown script",
3134 .type = P_STRING,
3135 .p_class = P_GLOBAL,
3136 .ptr = &Globals.szShutdownScript,
3137 .special = NULL,
3138 .enum_list = NULL,
3139 .flags = FLAG_ADVANCED,
3140 },
3141 {
3142 .label = "abort shutdown script",
3143 .type = P_STRING,
3144 .p_class = P_GLOBAL,
3145 .ptr = &Globals.szAbortShutdownScript,
3146 .special = NULL,
3147 .enum_list = NULL,
3148 .flags = FLAG_ADVANCED,
3149 },
3150 {
3151 .label = "username map script",
3152 .type = P_STRING,
3153 .p_class = P_GLOBAL,
3154 .ptr = &Globals.szUsernameMapScript,
3155 .special = NULL,
3156 .enum_list = NULL,
3157 .flags = FLAG_ADVANCED,
3158 },
3159 {
3160 .label = "logon script",
3161 .type = P_STRING,
3162 .p_class = P_GLOBAL,
3163 .ptr = &Globals.szLogonScript,
3164 .special = NULL,
3165 .enum_list = NULL,
3166 .flags = FLAG_ADVANCED,
3167 },
3168 {
3169 .label = "logon path",
3170 .type = P_STRING,
3171 .p_class = P_GLOBAL,
3172 .ptr = &Globals.szLogonPath,
3173 .special = NULL,
3174 .enum_list = NULL,
3175 .flags = FLAG_ADVANCED,
3176 },
3177 {
3178 .label = "logon drive",
3179 .type = P_STRING,
3180 .p_class = P_GLOBAL,
3181 .ptr = &Globals.szLogonDrive,
3182 .special = NULL,
3183 .enum_list = NULL,
3184 .flags = FLAG_ADVANCED,
3185 },
3186 {
3187 .label = "logon home",
3188 .type = P_STRING,
3189 .p_class = P_GLOBAL,
3190 .ptr = &Globals.szLogonHome,
3191 .special = NULL,
3192 .enum_list = NULL,
3193 .flags = FLAG_ADVANCED,
3194 },
3195 {
3196 .label = "domain logons",
3197 .type = P_BOOL,
3198 .p_class = P_GLOBAL,
3199 .ptr = &Globals.bDomainLogons,
3200 .special = NULL,
3201 .enum_list = NULL,
3202 .flags = FLAG_ADVANCED,
3203 },
3204
3205 {
3206 .label = "init logon delayed hosts",
3207 .type = P_LIST,
3208 .p_class = P_GLOBAL,
3209 .ptr = &Globals.szInitLogonDelayedHosts,
3210 .flags = FLAG_ADVANCED,
3211 },
3212
3213 {
3214 .label = "init logon delay",
3215 .type = P_INTEGER,
3216 .p_class = P_GLOBAL,
3217 .ptr = &Globals.InitLogonDelay,
3218 .flags = FLAG_ADVANCED,
3219
3220 },
3221
3222 {N_("Browse Options"), P_SEP, P_SEPARATOR},
3223
3224 {
3225 .label = "os level",
3226 .type = P_INTEGER,
3227 .p_class = P_GLOBAL,
3228 .ptr = &Globals.os_level,
3229 .special = NULL,
3230 .enum_list = NULL,
3231 .flags = FLAG_BASIC | FLAG_ADVANCED,
3232 },
3233 {
3234 .label = "lm announce",
3235 .type = P_ENUM,
3236 .p_class = P_GLOBAL,
3237 .ptr = &Globals.lm_announce,
3238 .special = NULL,
3239 .enum_list = enum_bool_auto,
3240 .flags = FLAG_ADVANCED,
3241 },
3242 {
3243 .label = "lm interval",
3244 .type = P_INTEGER,
3245 .p_class = P_GLOBAL,
3246 .ptr = &Globals.lm_interval,
3247 .special = NULL,
3248 .enum_list = NULL,
3249 .flags = FLAG_ADVANCED,
3250 },
3251 {
3252 .label = "preferred master",
3253 .type = P_ENUM,
3254 .p_class = P_GLOBAL,
3255 .ptr = &Globals.iPreferredMaster,
3256 .special = NULL,
3257 .enum_list = enum_bool_auto,
3258 .flags = FLAG_BASIC | FLAG_ADVANCED,
3259 },
3260 {
3261 .label = "prefered master",
3262 .type = P_ENUM,
3263 .p_class = P_GLOBAL,
3264 .ptr = &Globals.iPreferredMaster,
3265 .special = NULL,
3266 .enum_list = enum_bool_auto,
3267 .flags = FLAG_HIDE,
3268 },
3269 {
3270 .label = "local master",
3271 .type = P_BOOL,
3272 .p_class = P_GLOBAL,
3273 .ptr = &Globals.bLocalMaster,
3274 .special = NULL,
3275 .enum_list = NULL,
3276 .flags = FLAG_BASIC | FLAG_ADVANCED,
3277 },
3278 {
3279 .label = "domain master",
3280 .type = P_ENUM,
3281 .p_class = P_GLOBAL,
3282 .ptr = &Globals.iDomainMaster,
3283 .special = NULL,
3284 .enum_list = enum_bool_auto,
3285 .flags = FLAG_BASIC | FLAG_ADVANCED,
3286 },
3287 {
3288 .label = "browse list",
3289 .type = P_BOOL,
3290 .p_class = P_GLOBAL,
3291 .ptr = &Globals.bBrowseList,
3292 .special = NULL,
3293 .enum_list = NULL,
3294 .flags = FLAG_ADVANCED,
3295 },
3296 {
3297 .label = "browseable",
3298 .type = P_BOOL,
3299 .p_class = P_LOCAL,
3300 .ptr = &sDefault.bBrowseable,
3301 .special = NULL,
3302 .enum_list = NULL,
3303 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3304 },
3305 {
3306 .label = "browsable",
3307 .type = P_BOOL,
3308 .p_class = P_LOCAL,
3309 .ptr = &sDefault.bBrowseable,
3310 .special = NULL,
3311 .enum_list = NULL,
3312 .flags = FLAG_HIDE,
3313 },
3314 {
3315 .label = "enhanced browsing",
3316 .type = P_BOOL,
3317 .p_class = P_GLOBAL,
3318 .ptr = &Globals.enhanced_browsing,
3319 .special = NULL,
3320 .enum_list = NULL,
3321 .flags = FLAG_ADVANCED,
3322 },
3323
3324 {N_("WINS Options"), P_SEP, P_SEPARATOR},
3325
3326 {
3327 .label = "dns proxy",
3328 .type = P_BOOL,
3329 .p_class = P_GLOBAL,
3330 .ptr = &Globals.bDNSproxy,
3331 .special = NULL,
3332 .enum_list = NULL,
3333 .flags = FLAG_ADVANCED,
3334 },
3335 {
3336 .label = "wins proxy",
3337 .type = P_BOOL,
3338 .p_class = P_GLOBAL,
3339 .ptr = &Globals.bWINSproxy,
3340 .special = NULL,
3341 .enum_list = NULL,
3342 .flags = FLAG_ADVANCED,
3343 },
3344 {
3345 .label = "wins server",
3346 .type = P_LIST,
3347 .p_class = P_GLOBAL,
3348 .ptr = &Globals.szWINSservers,
3349 .special = NULL,
3350 .enum_list = NULL,
3351 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3352 },
3353 {
3354 .label = "wins support",
3355 .type = P_BOOL,
3356 .p_class = P_GLOBAL,
3357 .ptr = &Globals.bWINSsupport,
3358 .special = NULL,
3359 .enum_list = NULL,
3360 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
3361 },
3362 {
3363 .label = "wins hook",
3364 .type = P_STRING,
3365 .p_class = P_GLOBAL,
3366 .ptr = &Globals.szWINSHook,
3367 .special = NULL,
3368 .enum_list = NULL,
3369 .flags = FLAG_ADVANCED,
3370 },
3371
3372 {N_("Locking Options"), P_SEP, P_SEPARATOR},
3373
3374 {
3375 .label = "blocking locks",
3376 .type = P_BOOL,
3377 .p_class = P_LOCAL,
3378 .ptr = &sDefault.bBlockingLocks,
3379 .special = NULL,
3380 .enum_list = NULL,
3381 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3382 },
3383 {
3384 .label = "csc policy",
3385 .type = P_ENUM,
3386 .p_class = P_LOCAL,
3387 .ptr = &sDefault.iCSCPolicy,
3388 .special = NULL,
3389 .enum_list = enum_csc_policy,
3390 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3391 },
3392 {
3393 .label = "fake oplocks",
3394 .type = P_BOOL,
3395 .p_class = P_LOCAL,
3396 .ptr = &sDefault.bFakeOplocks,
3397 .special = NULL,
3398 .enum_list = NULL,
3399 .flags = FLAG_ADVANCED | FLAG_SHARE,
3400 },
3401 {
3402 .label = "kernel oplocks",
3403 .type = P_BOOL,
3404 .p_class = P_GLOBAL,
3405 .ptr = &Globals.bKernelOplocks,
3406 .special = NULL,
3407 .enum_list = NULL,
3408 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3409 },
3410 {
3411 .label = "locking",
3412 .type = P_BOOL,
3413 .p_class = P_LOCAL,
3414 .ptr = &sDefault.bLocking,
3415 .special = NULL,
3416 .enum_list = NULL,
3417 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3418 },
3419 {
3420 .label = "lock spin time",
3421 .type = P_INTEGER,
3422 .p_class = P_GLOBAL,
3423 .ptr = &Globals.iLockSpinTime,
3424 .special = NULL,
3425 .enum_list = NULL,
3426 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3427 },
3428 {
3429 .label = "oplocks",
3430 .type = P_BOOL,
3431 .p_class = P_LOCAL,
3432 .ptr = &sDefault.bOpLocks,
3433 .special = NULL,
3434 .enum_list = NULL,
3435 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3436 },
3437 {
3438 .label = "level2 oplocks",
3439 .type = P_BOOL,
3440 .p_class = P_LOCAL,
3441 .ptr = &sDefault.bLevel2OpLocks,
3442 .special = NULL,
3443 .enum_list = NULL,
3444 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3445 },
3446 {
3447 .label = "oplock break wait time",
3448 .type = P_INTEGER,
3449 .p_class = P_GLOBAL,
3450 .ptr = &Globals.oplock_break_wait_time,
3451 .special = NULL,
3452 .enum_list = NULL,
3453 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
3454 },
3455 {
3456 .label = "oplock contention limit",
3457 .type = P_INTEGER,
3458 .p_class = P_LOCAL,
3459 .ptr = &sDefault.iOplockContentionLimit,
3460 .special = NULL,
3461 .enum_list = NULL,
3462 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3463 },
3464 {
3465 .label = "posix locking",
3466 .type = P_BOOL,
3467 .p_class = P_LOCAL,
3468 .ptr = &sDefault.bPosixLocking,
3469 .special = NULL,
3470 .enum_list = NULL,
3471 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3472 },
3473 {
3474 .label = "strict locking",
3475 .type = P_ENUM,
3476 .p_class = P_LOCAL,
3477 .ptr = &sDefault.iStrictLocking,
3478 .special = NULL,
3479 .enum_list = enum_bool_auto,
3480 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
3481 },
3482 {
3483 .label = "share modes",
3484 .type = P_BOOL,
3485 .p_class = P_LOCAL,
3486 .ptr = &sDefault.bShareModes,
3487 .special = NULL,
3488 .enum_list = NULL,
3489 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED,
3490 },
3491
3492 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
3493
3494 {
3495 .label = "ldap admin dn",
3496 .type = P_STRING,
3497 .p_class = P_GLOBAL,
3498 .ptr = &Globals.szLdapAdminDn,
3499 .special = NULL,
3500 .enum_list = NULL,
3501 .flags = FLAG_ADVANCED,
3502 },
3503 {
3504 .label = "ldap delete dn",
3505 .type = P_BOOL,
3506 .p_class = P_GLOBAL,
3507 .ptr = &Globals.ldap_delete_dn,
3508 .special = NULL,
3509 .enum_list = NULL,
3510 .flags = FLAG_ADVANCED,
3511 },
3512 {
3513 .label = "ldap group suffix",
3514 .type = P_STRING,
3515 .p_class = P_GLOBAL,
3516 .ptr = &Globals.szLdapGroupSuffix,
3517 .special = NULL,
3518 .enum_list = NULL,
3519 .flags = FLAG_ADVANCED,
3520 },
3521 {
3522 .label = "ldap idmap suffix",
3523 .type = P_STRING,
3524 .p_class = P_GLOBAL,
3525 .ptr = &Globals.szLdapIdmapSuffix,
3526 .special = NULL,
3527 .enum_list = NULL,
3528 .flags = FLAG_ADVANCED,
3529 },
3530 {
3531 .label = "ldap machine suffix",
3532 .type = P_STRING,
3533 .p_class = P_GLOBAL,
3534 .ptr = &Globals.szLdapMachineSuffix,
3535 .special = NULL,
3536 .enum_list = NULL,
3537 .flags = FLAG_ADVANCED,
3538 },
3539 {
3540 .label = "ldap passwd sync",
3541 .type = P_ENUM,
3542 .p_class = P_GLOBAL,
3543 .ptr = &Globals.ldap_passwd_sync,
3544 .special = NULL,
3545 .enum_list = enum_ldap_passwd_sync,
3546 .flags = FLAG_ADVANCED,
3547 },
3548 {
3549 .label = "ldap password sync",
3550 .type = P_ENUM,
3551 .p_class = P_GLOBAL,
3552 .ptr = &Globals.ldap_passwd_sync,
3553 .special = NULL,
3554 .enum_list = enum_ldap_passwd_sync,
3555 .flags = FLAG_HIDE,
3556 },
3557 {
3558 .label = "ldap replication sleep",
3559 .type = P_INTEGER,
3560 .p_class = P_GLOBAL,
3561 .ptr = &Globals.ldap_replication_sleep,
3562 .special = NULL,
3563 .enum_list = NULL,
3564 .flags = FLAG_ADVANCED,
3565 },
3566 {
3567 .label = "ldap suffix",
3568 .type = P_STRING,
3569 .p_class = P_GLOBAL,
3570 .ptr = &Globals.szLdapSuffix,
3571 .special = NULL,
3572 .enum_list = NULL,
3573 .flags = FLAG_ADVANCED,
3574 },
3575 {
3576 .label = "ldap ssl",
3577 .type = P_ENUM,
3578 .p_class = P_GLOBAL,
3579 .ptr = &Globals.ldap_ssl,
3580 .special = NULL,
3581 .enum_list = enum_ldap_ssl,
3582 .flags = FLAG_ADVANCED,
3583 },
3584 {
3585 .label = "ldap ssl ads",
3586 .type = P_BOOL,
3587 .p_class = P_GLOBAL,
3588 .ptr = &Globals.ldap_ssl_ads,
3589 .special = NULL,
3590 .enum_list = NULL,
3591 .flags = FLAG_ADVANCED,
3592 },
3593 {
3594 .label = "ldap timeout",
3595 .type = P_INTEGER,
3596 .p_class = P_GLOBAL,
3597 .ptr = &Globals.ldap_timeout,
3598 .special = NULL,
3599 .enum_list = NULL,
3600 .flags = FLAG_ADVANCED,
3601 },
3602 {
3603 .label = "ldap connection timeout",
3604 .type = P_INTEGER,
3605 .p_class = P_GLOBAL,
3606 .ptr = &Globals.ldap_connection_timeout,
3607 .special = NULL,
3608 .enum_list = NULL,
3609 .flags = FLAG_ADVANCED,
3610 },
3611 {
3612 .label = "ldap page size",
3613 .type = P_INTEGER,
3614 .p_class = P_GLOBAL,
3615 .ptr = &Globals.ldap_page_size,
3616 .special = NULL,
3617 .enum_list = NULL,
3618 .flags = FLAG_ADVANCED,
3619 },
3620 {
3621 .label = "ldap user suffix",
3622 .type = P_STRING,
3623 .p_class = P_GLOBAL,
3624 .ptr = &Globals.szLdapUserSuffix,
3625 .special = NULL,
3626 .enum_list = NULL,
3627 .flags = FLAG_ADVANCED,
3628 },
3629 {
3630 .label = "ldap debug level",
3631 .type = P_INTEGER,
3632 .p_class = P_GLOBAL,
3633 .ptr = &Globals.ldap_debug_level,
3634 .special = handle_ldap_debug_level,
3635 .enum_list = NULL,
3636 .flags = FLAG_ADVANCED,
3637 },
3638 {
3639 .label = "ldap debug threshold",
3640 .type = P_INTEGER,
3641 .p_class = P_GLOBAL,
3642 .ptr = &Globals.ldap_debug_threshold,
3643 .special = NULL,
3644 .enum_list = NULL,
3645 .flags = FLAG_ADVANCED,
3646 },
3647
3648 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
3649
3650 {
3651 .label = "eventlog list",
3652 .type = P_LIST,
3653 .p_class = P_GLOBAL,
3654 .ptr = &Globals.szEventLogs,
3655 .special = NULL,
3656 .enum_list = NULL,
3657 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
3658 },
3659
3660 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
3661
3662 {
3663 .label = "add share command",
3664 .type = P_STRING,
3665 .p_class = P_GLOBAL,
3666 .ptr = &Globals.szAddShareCommand,
3667 .special = NULL,
3668 .enum_list = NULL,
3669 .flags = FLAG_ADVANCED,
3670 },
3671 {
3672 .label = "change share command",
3673 .type = P_STRING,
3674 .p_class = P_GLOBAL,
3675 .ptr = &Globals.szChangeShareCommand,
3676 .special = NULL,
3677 .enum_list = NULL,
3678 .flags = FLAG_ADVANCED,
3679 },
3680 {
3681 .label = "delete share command",
3682 .type = P_STRING,
3683 .p_class = P_GLOBAL,
3684 .ptr = &Globals.szDeleteShareCommand,
3685 .special = NULL,
3686 .enum_list = NULL,
3687 .flags = FLAG_ADVANCED,
3688 },
3689 {
3690 .label = "config file",
3691 .type = P_STRING,
3692 .p_class = P_GLOBAL,
3693 .ptr = &Globals.szConfigFile,
3694 .special = NULL,
3695 .enum_list = NULL,
3696 .flags = FLAG_HIDE,
3697 },
3698 {
3699 .label = "preload",
3700 .type = P_STRING,
3701 .p_class = P_GLOBAL,
3702 .ptr = &Globals.szAutoServices,
3703 .special = NULL,
3704 .enum_list = NULL,
3705 .flags = FLAG_ADVANCED,
3706 },
3707 {
3708 .label = "auto services",
3709 .type = P_STRING,
3710 .p_class = P_GLOBAL,
3711 .ptr = &Globals.szAutoServices,
3712 .special = NULL,
3713 .enum_list = NULL,
3714 .flags = FLAG_ADVANCED,
3715 },
3716 {
3717 .label = "lock directory",
3718 .type = P_STRING,
3719 .p_class = P_GLOBAL,
3720 .ptr = &Globals.szLockDir,
3721 .special = NULL,
3722 .enum_list = NULL,
3723 .flags = FLAG_ADVANCED,
3724 },
3725 {
3726 .label = "lock dir",
3727 .type = P_STRING,
3728 .p_class = P_GLOBAL,
3729 .ptr = &Globals.szLockDir,
3730 .special = NULL,
3731 .enum_list = NULL,
3732 .flags = FLAG_HIDE,
3733 },
3734 {
3735 .label = "pid directory",
3736 .type = P_STRING,
3737 .p_class = P_GLOBAL,
3738 .ptr = &Globals.szPidDir,
3739 .special = NULL,
3740 .enum_list = NULL,
3741 .flags = FLAG_ADVANCED,
3742 },
3743#ifdef WITH_UTMP
3744 {
3745 .label = "utmp directory",
3746 .type = P_STRING,
3747 .p_class = P_GLOBAL,
3748 .ptr = &Globals.szUtmpDir,
3749 .special = NULL,
3750 .enum_list = NULL,
3751 .flags = FLAG_ADVANCED,
3752 },
3753 {
3754 .label = "wtmp directory",
3755 .type = P_STRING,
3756 .p_class = P_GLOBAL,
3757 .ptr = &Globals.szWtmpDir,
3758 .special = NULL,
3759 .enum_list = NULL,
3760 .flags = FLAG_ADVANCED,
3761 },
3762 {
3763 .label = "utmp",
3764 .type = P_BOOL,
3765 .p_class = P_GLOBAL,
3766 .ptr = &Globals.bUtmp,
3767 .special = NULL,
3768 .enum_list = NULL,
3769 .flags = FLAG_ADVANCED,
3770 },
3771#endif
3772 {
3773 .label = "default service",
3774 .type = P_STRING,
3775 .p_class = P_GLOBAL,
3776 .ptr = &Globals.szDefaultService,
3777 .special = NULL,
3778 .enum_list = NULL,
3779 .flags = FLAG_ADVANCED,
3780 },
3781 {
3782 .label = "default",
3783 .type = P_STRING,
3784 .p_class = P_GLOBAL,
3785 .ptr = &Globals.szDefaultService,
3786 .special = NULL,
3787 .enum_list = NULL,
3788 .flags = FLAG_ADVANCED,
3789 },
3790 {
3791 .label = "message command",
3792 .type = P_STRING,
3793 .p_class = P_GLOBAL,
3794 .ptr = &Globals.szMsgCommand,
3795 .special = NULL,
3796 .enum_list = NULL,
3797 .flags = FLAG_ADVANCED,
3798 },
3799 {
3800 .label = "dfree cache time",
3801 .type = P_INTEGER,
3802 .p_class = P_LOCAL,
3803 .ptr = &sDefault.iDfreeCacheTime,
3804 .special = NULL,
3805 .enum_list = NULL,
3806 .flags = FLAG_ADVANCED,
3807 },
3808 {
3809 .label = "dfree command",
3810 .type = P_STRING,
3811 .p_class = P_LOCAL,
3812 .ptr = &sDefault.szDfree,
3813 .special = NULL,
3814 .enum_list = NULL,
3815 .flags = FLAG_ADVANCED,
3816 },
3817 {
3818 .label = "get quota command",
3819 .type = P_STRING,
3820 .p_class = P_GLOBAL,
3821 .ptr = &Globals.szGetQuota,
3822 .special = NULL,
3823 .enum_list = NULL,
3824 .flags = FLAG_ADVANCED,
3825 },
3826 {
3827 .label = "set quota command",
3828 .type = P_STRING,
3829 .p_class = P_GLOBAL,
3830 .ptr = &Globals.szSetQuota,
3831 .special = NULL,
3832 .enum_list = NULL,
3833 .flags = FLAG_ADVANCED,
3834 },
3835 {
3836 .label = "remote announce",
3837 .type = P_STRING,
3838 .p_class = P_GLOBAL,
3839 .ptr = &Globals.szRemoteAnnounce,
3840 .special = NULL,
3841 .enum_list = NULL,
3842 .flags = FLAG_ADVANCED,
3843 },
3844 {
3845 .label = "remote browse sync",
3846 .type = P_STRING,
3847 .p_class = P_GLOBAL,
3848 .ptr = &Globals.szRemoteBrowseSync,
3849 .special = NULL,
3850 .enum_list = NULL,
3851 .flags = FLAG_ADVANCED,
3852 },
3853 {
3854 .label = "socket address",
3855 .type = P_STRING,
3856 .p_class = P_GLOBAL,
3857 .ptr = &Globals.szSocketAddress,
3858 .special = NULL,
3859 .enum_list = NULL,
3860 .flags = FLAG_ADVANCED,
3861 },
3862 {
3863 .label = "homedir map",
3864 .type = P_STRING,
3865 .p_class = P_GLOBAL,
3866 .ptr = &Globals.szNISHomeMapName,
3867 .special = NULL,
3868 .enum_list = NULL,
3869 .flags = FLAG_ADVANCED,
3870 },
3871 {
3872 .label = "afs username map",
3873 .type = P_STRING,
3874 .p_class = P_GLOBAL,
3875 .ptr = &Globals.szAfsUsernameMap,
3876 .special = NULL,
3877 .enum_list = NULL,
3878 .flags = FLAG_ADVANCED,
3879 },
3880 {
3881 .label = "afs token lifetime",
3882 .type = P_INTEGER,
3883 .p_class = P_GLOBAL,
3884 .ptr = &Globals.iAfsTokenLifetime,
3885 .special = NULL,
3886 .enum_list = NULL,
3887 .flags = FLAG_ADVANCED,
3888 },
3889 {
3890 .label = "log nt token command",
3891 .type = P_STRING,
3892 .p_class = P_GLOBAL,
3893 .ptr = &Globals.szLogNtTokenCommand,
3894 .special = NULL,
3895 .enum_list = NULL,
3896 .flags = FLAG_ADVANCED,
3897 },
3898 {
3899 .label = "time offset",
3900 .type = P_INTEGER,
3901 .p_class = P_GLOBAL,
3902 .ptr = &extra_time_offset,
3903 .special = NULL,
3904 .enum_list = NULL,
3905 .flags = FLAG_ADVANCED,
3906 },
3907 {
3908 .label = "NIS homedir",
3909 .type = P_BOOL,
3910 .p_class = P_GLOBAL,
3911 .ptr = &Globals.bNISHomeMap,
3912 .special = NULL,
3913 .enum_list = NULL,
3914 .flags = FLAG_ADVANCED,
3915 },
3916 {
3917 .label = "-valid",
3918 .type = P_BOOL,
3919 .p_class = P_LOCAL,
3920 .ptr = &sDefault.valid,
3921 .special = NULL,
3922 .enum_list = NULL,
3923 .flags = FLAG_HIDE,
3924 },
3925 {
3926 .label = "copy",
3927 .type = P_STRING,
3928 .p_class = P_LOCAL,
3929 .ptr = &sDefault.szCopy,
3930 .special = handle_copy,
3931 .enum_list = NULL,
3932 .flags = FLAG_HIDE,
3933 },
3934 {
3935 .label = "include",
3936 .type = P_STRING,
3937 .p_class = P_LOCAL,
3938 .ptr = &sDefault.szInclude,
3939 .special = handle_include,
3940 .enum_list = NULL,
3941 .flags = FLAG_HIDE,
3942 },
3943 {
3944 .label = "preexec",
3945 .type = P_STRING,
3946 .p_class = P_LOCAL,
3947 .ptr = &sDefault.szPreExec,
3948 .special = NULL,
3949 .enum_list = NULL,
3950 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3951 },
3952 {
3953 .label = "exec",
3954 .type = P_STRING,
3955 .p_class = P_LOCAL,
3956 .ptr = &sDefault.szPreExec,
3957 .special = NULL,
3958 .enum_list = NULL,
3959 .flags = FLAG_ADVANCED,
3960 },
3961 {
3962 .label = "preexec close",
3963 .type = P_BOOL,
3964 .p_class = P_LOCAL,
3965 .ptr = &sDefault.bPreexecClose,
3966 .special = NULL,
3967 .enum_list = NULL,
3968 .flags = FLAG_ADVANCED | FLAG_SHARE,
3969 },
3970 {
3971 .label = "postexec",
3972 .type = P_STRING,
3973 .p_class = P_LOCAL,
3974 .ptr = &sDefault.szPostExec,
3975 .special = NULL,
3976 .enum_list = NULL,
3977 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3978 },
3979 {
3980 .label = "root preexec",
3981 .type = P_STRING,
3982 .p_class = P_LOCAL,
3983 .ptr = &sDefault.szRootPreExec,
3984 .special = NULL,
3985 .enum_list = NULL,
3986 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
3987 },
3988 {
3989 .label = "root preexec close",
3990 .type = P_BOOL,
3991 .p_class = P_LOCAL,
3992 .ptr = &sDefault.bRootpreexecClose,
3993 .special = NULL,
3994 .enum_list = NULL,
3995 .flags = FLAG_ADVANCED | FLAG_SHARE,
3996 },
3997 {
3998 .label = "root postexec",
3999 .type = P_STRING,
4000 .p_class = P_LOCAL,
4001 .ptr = &sDefault.szRootPostExec,
4002 .special = NULL,
4003 .enum_list = NULL,
4004 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4005 },
4006 {
4007 .label = "available",
4008 .type = P_BOOL,
4009 .p_class = P_LOCAL,
4010 .ptr = &sDefault.bAvailable,
4011 .special = NULL,
4012 .enum_list = NULL,
4013 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
4014 },
4015 {
4016 .label = "registry shares",
4017 .type = P_BOOL,
4018 .p_class = P_GLOBAL,
4019 .ptr = &Globals.bRegistryShares,
4020 .special = NULL,
4021 .enum_list = NULL,
4022 .flags = FLAG_ADVANCED,
4023 },
4024 {
4025 .label = "usershare allow guests",
4026 .type = P_BOOL,
4027 .p_class = P_GLOBAL,
4028 .ptr = &Globals.bUsershareAllowGuests,
4029 .special = NULL,
4030 .enum_list = NULL,
4031 .flags = FLAG_ADVANCED,
4032 },
4033 {
4034 .label = "usershare max shares",
4035 .type = P_INTEGER,
4036 .p_class = P_GLOBAL,
4037 .ptr = &Globals.iUsershareMaxShares,
4038 .special = NULL,
4039 .enum_list = NULL,
4040 .flags = FLAG_ADVANCED,
4041 },
4042 {
4043 .label = "usershare owner only",
4044 .type = P_BOOL,
4045 .p_class = P_GLOBAL,
4046 .ptr = &Globals.bUsershareOwnerOnly,
4047 .special = NULL,
4048 .enum_list = NULL,
4049 .flags = FLAG_ADVANCED,
4050 },
4051 {
4052 .label = "usershare path",
4053 .type = P_STRING,
4054 .p_class = P_GLOBAL,
4055 .ptr = &Globals.szUsersharePath,
4056 .special = NULL,
4057 .enum_list = NULL,
4058 .flags = FLAG_ADVANCED,
4059 },
4060 {
4061 .label = "usershare prefix allow list",
4062 .type = P_LIST,
4063 .p_class = P_GLOBAL,
4064 .ptr = &Globals.szUsersharePrefixAllowList,
4065 .special = NULL,
4066 .enum_list = NULL,
4067 .flags = FLAG_ADVANCED,
4068 },
4069 {
4070 .label = "usershare prefix deny list",
4071 .type = P_LIST,
4072 .p_class = P_GLOBAL,
4073 .ptr = &Globals.szUsersharePrefixDenyList,
4074 .special = NULL,
4075 .enum_list = NULL,
4076 .flags = FLAG_ADVANCED,
4077 },
4078 {
4079 .label = "usershare template share",
4080 .type = P_STRING,
4081 .p_class = P_GLOBAL,
4082 .ptr = &Globals.szUsershareTemplateShare,
4083 .special = NULL,
4084 .enum_list = NULL,
4085 .flags = FLAG_ADVANCED,
4086 },
4087 {
4088 .label = "volume",
4089 .type = P_STRING,
4090 .p_class = P_LOCAL,
4091 .ptr = &sDefault.volume,
4092 .special = NULL,
4093 .enum_list = NULL,
4094 .flags = FLAG_ADVANCED | FLAG_SHARE,
4095 },
4096 {
4097 .label = "fstype",
4098 .type = P_STRING,
4099 .p_class = P_LOCAL,
4100 .ptr = &sDefault.fstype,
4101 .special = NULL,
4102 .enum_list = NULL,
4103 .flags = FLAG_ADVANCED | FLAG_SHARE,
4104 },
4105 {
4106 .label = "set directory",
4107 .type = P_BOOLREV,
4108 .p_class = P_LOCAL,
4109 .ptr = &sDefault.bNo_set_dir,
4110 .special = NULL,
4111 .enum_list = NULL,
4112 .flags = FLAG_ADVANCED | FLAG_SHARE,
4113 },
4114 {
4115 .label = "wide links",
4116 .type = P_BOOL,
4117 .p_class = P_LOCAL,
4118 .ptr = &sDefault.bWidelinks,
4119 .special = NULL,
4120 .enum_list = NULL,
4121 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4122 },
4123 {
4124 .label = "follow symlinks",
4125 .type = P_BOOL,
4126 .p_class = P_LOCAL,
4127 .ptr = &sDefault.bSymlinks,
4128 .special = NULL,
4129 .enum_list = NULL,
4130 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4131 },
4132 {
4133 .label = "dont descend",
4134 .type = P_STRING,
4135 .p_class = P_LOCAL,
4136 .ptr = &sDefault.szDontdescend,
4137 .special = NULL,
4138 .enum_list = NULL,
4139 .flags = FLAG_ADVANCED | FLAG_SHARE,
4140 },
4141 {
4142 .label = "magic script",
4143 .type = P_STRING,
4144 .p_class = P_LOCAL,
4145 .ptr = &sDefault.szMagicScript,
4146 .special = NULL,
4147 .enum_list = NULL,
4148 .flags = FLAG_ADVANCED | FLAG_SHARE,
4149 },
4150 {
4151 .label = "magic output",
4152 .type = P_STRING,
4153 .p_class = P_LOCAL,
4154 .ptr = &sDefault.szMagicOutput,
4155 .special = NULL,
4156 .enum_list = NULL,
4157 .flags = FLAG_ADVANCED | FLAG_SHARE,
4158 },
4159 {
4160 .label = "delete readonly",
4161 .type = P_BOOL,
4162 .p_class = P_LOCAL,
4163 .ptr = &sDefault.bDeleteReadonly,
4164 .special = NULL,
4165 .enum_list = NULL,
4166 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4167 },
4168 {
4169 .label = "dos filemode",
4170 .type = P_BOOL,
4171 .p_class = P_LOCAL,
4172 .ptr = &sDefault.bDosFilemode,
4173 .special = NULL,
4174 .enum_list = NULL,
4175 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4176 },
4177 {
4178 .label = "dos filetimes",
4179 .type = P_BOOL,
4180 .p_class = P_LOCAL,
4181 .ptr = &sDefault.bDosFiletimes,
4182 .special = NULL,
4183 .enum_list = NULL,
4184 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4185 },
4186 {
4187 .label = "dos filetime resolution",
4188 .type = P_BOOL,
4189 .p_class = P_LOCAL,
4190 .ptr = &sDefault.bDosFiletimeResolution,
4191 .special = NULL,
4192 .enum_list = NULL,
4193 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4194 },
4195 {
4196 .label = "fake directory create times",
4197 .type = P_BOOL,
4198 .p_class = P_LOCAL,
4199 .ptr = &sDefault.bFakeDirCreateTimes,
4200 .special = NULL,
4201 .enum_list = NULL,
4202 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
4203 },
4204 {
4205 .label = "panic action",
4206 .type = P_STRING,
4207 .p_class = P_GLOBAL,
4208 .ptr = &Globals.szPanicAction,
4209 .special = NULL,
4210 .enum_list = NULL,
4211 .flags = FLAG_ADVANCED,
4212 },
4213
4214 {N_("VFS module options"), P_SEP, P_SEPARATOR},
4215
4216 {
4217 .label = "vfs objects",
4218 .type = P_LIST,
4219 .p_class = P_LOCAL,
4220 .ptr = &sDefault.szVfsObjects,
4221 .special = NULL,
4222 .enum_list = NULL,
4223 .flags = FLAG_ADVANCED | FLAG_SHARE,
4224 },
4225 {
4226 .label = "vfs object",
4227 .type = P_LIST,
4228 .p_class = P_LOCAL,
4229 .ptr = &sDefault.szVfsObjects,
4230 .special = NULL,
4231 .enum_list = NULL,
4232 .flags = FLAG_HIDE,
4233 },
4234
4235
4236 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
4237
4238 {
4239 .label = "msdfs root",
4240 .type = P_BOOL,
4241 .p_class = P_LOCAL,
4242 .ptr = &sDefault.bMSDfsRoot,
4243 .special = NULL,
4244 .enum_list = NULL,
4245 .flags = FLAG_ADVANCED | FLAG_SHARE,
4246 },
4247 {
4248 .label = "msdfs proxy",
4249 .type = P_STRING,
4250 .p_class = P_LOCAL,
4251 .ptr = &sDefault.szMSDfsProxy,
4252 .special = NULL,
4253 .enum_list = NULL,
4254 .flags = FLAG_ADVANCED | FLAG_SHARE,
4255 },
4256 {
4257 .label = "host msdfs",
4258 .type = P_BOOL,
4259 .p_class = P_GLOBAL,
4260 .ptr = &Globals.bHostMSDfs,
4261 .special = NULL,
4262 .enum_list = NULL,
4263 .flags = FLAG_ADVANCED,
4264 },
4265
4266 {N_("Winbind options"), P_SEP, P_SEPARATOR},
4267
4268 {
4269 .label = "passdb expand explicit",
4270 .type = P_BOOL,
4271 .p_class = P_GLOBAL,
4272 .ptr = &Globals.bPassdbExpandExplicit,
4273 .special = NULL,
4274 .enum_list = NULL,
4275 .flags = FLAG_ADVANCED,
4276 },
4277 {
4278 .label = "idmap backend",
4279 .type = P_STRING,
4280 .p_class = P_GLOBAL,
4281 .ptr = &Globals.szIdmapBackend,
4282 .special = NULL,
4283 .enum_list = NULL,
4284 .flags = FLAG_ADVANCED,
4285 },
4286 {
4287 .label = "idmap alloc backend",
4288 .type = P_STRING,
4289 .p_class = P_GLOBAL,
4290 .ptr = &Globals.szIdmapAllocBackend,
4291 .special = NULL,
4292 .enum_list = NULL,
4293 .flags = FLAG_ADVANCED,
4294 },
4295 {
4296 .label = "idmap cache time",
4297 .type = P_INTEGER,
4298 .p_class = P_GLOBAL,
4299 .ptr = &Globals.iIdmapCacheTime,
4300 .special = NULL,
4301 .enum_list = NULL,
4302 .flags = FLAG_ADVANCED,
4303 },
4304 {
4305 .label = "idmap negative cache time",
4306 .type = P_INTEGER,
4307 .p_class = P_GLOBAL,
4308 .ptr = &Globals.iIdmapNegativeCacheTime,
4309 .special = NULL,
4310 .enum_list = NULL,
4311 .flags = FLAG_ADVANCED,
4312 },
4313 {
4314 .label = "idmap uid",
4315 .type = P_STRING,
4316 .p_class = P_GLOBAL,
4317 .ptr = &Globals.szIdmapUID,
4318 .special = handle_idmap_uid,
4319 .enum_list = NULL,
4320 .flags = FLAG_ADVANCED,
4321 },
4322 {
4323 .label = "winbind uid",
4324 .type = P_STRING,
4325 .p_class = P_GLOBAL,
4326 .ptr = &Globals.szIdmapUID,
4327 .special = handle_idmap_uid,
4328 .enum_list = NULL,
4329 .flags = FLAG_HIDE,
4330 },
4331 {
4332 .label = "idmap gid",
4333 .type = P_STRING,
4334 .p_class = P_GLOBAL,
4335 .ptr = &Globals.szIdmapGID,
4336 .special = handle_idmap_gid,
4337 .enum_list = NULL,
4338 .flags = FLAG_ADVANCED,
4339 },
4340 {
4341 .label = "winbind gid",
4342 .type = P_STRING,
4343 .p_class = P_GLOBAL,
4344 .ptr = &Globals.szIdmapGID,
4345 .special = handle_idmap_gid,
4346 .enum_list = NULL,
4347 .flags = FLAG_HIDE,
4348 },
4349 {
4350 .label = "template homedir",
4351 .type = P_STRING,
4352 .p_class = P_GLOBAL,
4353 .ptr = &Globals.szTemplateHomedir,
4354 .special = NULL,
4355 .enum_list = NULL,
4356 .flags = FLAG_ADVANCED,
4357 },
4358 {
4359 .label = "template shell",
4360 .type = P_STRING,
4361 .p_class = P_GLOBAL,
4362 .ptr = &Globals.szTemplateShell,
4363 .special = NULL,
4364 .enum_list = NULL,
4365 .flags = FLAG_ADVANCED,
4366 },
4367 {
4368 .label = "winbind separator",
4369 .type = P_STRING,
4370 .p_class = P_GLOBAL,
4371 .ptr = &Globals.szWinbindSeparator,
4372 .special = NULL,
4373 .enum_list = NULL,
4374 .flags = FLAG_ADVANCED,
4375 },
4376 {
4377 .label = "winbind cache time",
4378 .type = P_INTEGER,
4379 .p_class = P_GLOBAL,
4380 .ptr = &Globals.winbind_cache_time,
4381 .special = NULL,
4382 .enum_list = NULL,
4383 .flags = FLAG_ADVANCED,
4384 },
4385 {
4386 .label = "winbind reconnect delay",
4387 .type = P_INTEGER,
4388 .p_class = P_GLOBAL,
4389 .ptr = &Globals.winbind_reconnect_delay,
4390 .special = NULL,
4391 .enum_list = NULL,
4392 .flags = FLAG_ADVANCED,
4393 },
4394 {
4395 .label = "winbind enum users",
4396 .type = P_BOOL,
4397 .p_class = P_GLOBAL,
4398 .ptr = &Globals.bWinbindEnumUsers,
4399 .special = NULL,
4400 .enum_list = NULL,
4401 .flags = FLAG_ADVANCED,
4402 },
4403 {
4404 .label = "winbind enum groups",
4405 .type = P_BOOL,
4406 .p_class = P_GLOBAL,
4407 .ptr = &Globals.bWinbindEnumGroups,
4408 .special = NULL,
4409 .enum_list = NULL,
4410 .flags = FLAG_ADVANCED,
4411 },
4412 {
4413 .label = "winbind use default domain",
4414 .type = P_BOOL,
4415 .p_class = P_GLOBAL,
4416 .ptr = &Globals.bWinbindUseDefaultDomain,
4417 .special = NULL,
4418 .enum_list = NULL,
4419 .flags = FLAG_ADVANCED,
4420 },
4421 {
4422 .label = "winbind trusted domains only",
4423 .type = P_BOOL,
4424 .p_class = P_GLOBAL,
4425 .ptr = &Globals.bWinbindTrustedDomainsOnly,
4426 .special = NULL,
4427 .enum_list = NULL,
4428 .flags = FLAG_ADVANCED,
4429 },
4430 {
4431 .label = "winbind nested groups",
4432 .type = P_BOOL,
4433 .p_class = P_GLOBAL,
4434 .ptr = &Globals.bWinbindNestedGroups,
4435 .special = NULL,
4436 .enum_list = NULL,
4437 .flags = FLAG_ADVANCED,
4438 },
4439 {
4440 .label = "winbind expand groups",
4441 .type = P_INTEGER,
4442 .p_class = P_GLOBAL,
4443 .ptr = &Globals.winbind_expand_groups,
4444 .special = NULL,
4445 .enum_list = NULL,
4446 .flags = FLAG_ADVANCED,
4447 },
4448 {
4449 .label = "winbind nss info",
4450 .type = P_LIST,
4451 .p_class = P_GLOBAL,
4452 .ptr = &Globals.szWinbindNssInfo,
4453 .special = NULL,
4454 .enum_list = NULL,
4455 .flags = FLAG_ADVANCED,
4456 },
4457 {
4458 .label = "winbind refresh tickets",
4459 .type = P_BOOL,
4460 .p_class = P_GLOBAL,
4461 .ptr = &Globals.bWinbindRefreshTickets,
4462 .special = NULL,
4463 .enum_list = NULL,
4464 .flags = FLAG_ADVANCED,
4465 },
4466 {
4467 .label = "winbind offline logon",
4468 .type = P_BOOL,
4469 .p_class = P_GLOBAL,
4470 .ptr = &Globals.bWinbindOfflineLogon,
4471 .special = NULL,
4472 .enum_list = NULL,
4473 .flags = FLAG_ADVANCED,
4474 },
4475 {
4476 .label = "winbind normalize names",
4477 .type = P_BOOL,
4478 .p_class = P_GLOBAL,
4479 .ptr = &Globals.bWinbindNormalizeNames,
4480 .special = NULL,
4481 .enum_list = NULL,
4482 .flags = FLAG_ADVANCED,
4483 },
4484 {
4485 .label = "winbind rpc only",
4486 .type = P_BOOL,
4487 .p_class = P_GLOBAL,
4488 .ptr = &Globals.bWinbindRpcOnly,
4489 .special = NULL,
4490 .enum_list = NULL,
4491 .flags = FLAG_ADVANCED,
4492 },
4493
4494 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
4495};
4496
4497/***************************************************************************
4498 Initialise the sDefault parameter structure for the printer values.
4499***************************************************************************/
4500
4501static void init_printer_values(struct service *pService)
4502{
4503 /* choose defaults depending on the type of printing */
4504 switch (pService->iPrinting) {
4505 case PRINT_BSD:
4506 case PRINT_AIX:
4507 case PRINT_LPRNT:
4508#ifndef __OS2__
4509 case PRINT_LPROS2:
4510#endif
4511 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4512 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4513 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4514 break;
4515#ifdef __OS2__
4516 case PRINT_LPROS2:
4517 string_set(&pService->szLpqcommand, "lpq.exe -s %i -p %p");
4518 string_set(&pService->szLprmcommand, "lprm.exe -s %i -p %p %j");
4519 string_set(&pService->szPrintcommand, "lpr.exe -b -s %i -p %p %s & cmd.exe /c del %s");
4520 break;
4521#endif
4522
4523 case PRINT_LPRNG:
4524 case PRINT_PLP:
4525 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4526 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4527 string_set(&pService->szPrintcommand, "lpr -r -P'%p' %s");
4528 string_set(&pService->szQueuepausecommand, "lpc stop '%p'");
4529 string_set(&pService->szQueueresumecommand, "lpc start '%p'");
4530 string_set(&pService->szLppausecommand, "lpc hold '%p' %j");
4531 string_set(&pService->szLpresumecommand, "lpc release '%p' %j");
4532 break;
4533
4534 case PRINT_CUPS:
4535 case PRINT_IPRINT:
4536#ifdef HAVE_CUPS
4537 /* set the lpq command to contain the destination printer
4538 name only. This is used by cups_queue_get() */
4539 string_set(&pService->szLpqcommand, "%p");
4540 string_set(&pService->szLprmcommand, "");
4541 string_set(&pService->szPrintcommand, "");
4542 string_set(&pService->szLppausecommand, "");
4543 string_set(&pService->szLpresumecommand, "");
4544 string_set(&pService->szQueuepausecommand, "");
4545 string_set(&pService->szQueueresumecommand, "");
4546#else
4547 string_set(&pService->szLpqcommand, "lpq -P'%p'");
4548 string_set(&pService->szLprmcommand, "lprm -P'%p' %j");
4549 string_set(&pService->szPrintcommand, "lpr -P'%p' %s; rm %s");
4550 string_set(&pService->szLppausecommand, "lp -i '%p-%j' -H hold");
4551 string_set(&pService->szLpresumecommand, "lp -i '%p-%j' -H resume");
4552 string_set(&pService->szQueuepausecommand, "disable '%p'");
4553 string_set(&pService->szQueueresumecommand, "enable '%p'");
4554#endif /* HAVE_CUPS */
4555 break;
4556
4557 case PRINT_SYSV:
4558 case PRINT_HPUX:
4559 string_set(&pService->szLpqcommand, "lpstat -o%p");
4560 string_set(&pService->szLprmcommand, "cancel %p-%j");
4561 string_set(&pService->szPrintcommand, "lp -c -d%p %s; rm %s");
4562 string_set(&pService->szQueuepausecommand, "disable %p");
4563 string_set(&pService->szQueueresumecommand, "enable %p");
4564#ifndef HPUX
4565 string_set(&pService->szLppausecommand, "lp -i %p-%j -H hold");
4566 string_set(&pService->szLpresumecommand, "lp -i %p-%j -H resume");
4567#endif /* HPUX */
4568 break;
4569
4570 case PRINT_QNX:
4571 string_set(&pService->szLpqcommand, "lpq -P%p");
4572 string_set(&pService->szLprmcommand, "lprm -P%p %j");
4573 string_set(&pService->szPrintcommand, "lp -r -P%p %s");
4574 break;
4575
4576#ifdef DEVELOPER
4577 case PRINT_TEST:
4578 case PRINT_VLP:
4579 string_set(&pService->szPrintcommand, "vlp print %p %s");
4580 string_set(&pService->szLpqcommand, "vlp lpq %p");
4581 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
4582 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
4583 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
4584 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
4585 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
4586 break;
4587#endif /* DEVELOPER */
4588
4589 }
4590}
4591
4592/***************************************************************************
4593 Initialise the global parameter structure.
4594***************************************************************************/
4595
4596static void init_globals(bool first_time_only)
4597{
4598 static bool done_init = False;
4599 char *s = NULL;
4600 int i;
4601
4602 /* If requested to initialize only once and we've already done it... */
4603 if (first_time_only && done_init) {
4604 /* ... then we have nothing more to do */
4605 return;
4606 }
4607
4608 if (!done_init) {
4609 /* The logfile can be set before this is invoked. Free it if so. */
4610 if (Globals.szLogFile != NULL) {
4611 string_free(&Globals.szLogFile);
4612 Globals.szLogFile = NULL;
4613 }
4614 done_init = True;
4615 } else {
4616 for (i = 0; parm_table[i].label; i++) {
4617 if ((parm_table[i].type == P_STRING ||
4618 parm_table[i].type == P_USTRING) &&
4619 parm_table[i].ptr)
4620 {
4621 string_free((char **)parm_table[i].ptr);
4622 }
4623 }
4624 }
4625
4626 memset((void *)&Globals, '\0', sizeof(Globals));
4627
4628 for (i = 0; parm_table[i].label; i++) {
4629 if ((parm_table[i].type == P_STRING ||
4630 parm_table[i].type == P_USTRING) &&
4631 parm_table[i].ptr)
4632 {
4633 string_set((char **)parm_table[i].ptr, "");
4634 }
4635 }
4636
4637 string_set(&sDefault.fstype, FSTYPE_STRING);
4638 string_set(&sDefault.szPrintjobUsername, "%U");
4639
4640 init_printer_values(&sDefault);
4641
4642
4643 DEBUG(3, ("Initialising global parameters\n"));
4644
4645 string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
4646 string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
4647
4648 /* use the new 'hash2' method by default, with a prefix of 1 */
4649 string_set(&Globals.szManglingMethod, "hash2");
4650 Globals.mangle_prefix = 1;
4651
4652 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
4653
4654#if defined (__OS2__)
4655 /* search the system codepage and set OS2CodePageStr */
4656 unsigned long _System DosQueryCp (unsigned long ulLength, unsigned long *pCodePageList, unsigned long *pDataLength);
4657 char *OS2CodePageStr=NULL;
4658 unsigned long OS2CodePage[3];
4659 unsigned long OS2CodePageLen;
4660 if ( DosQueryCp( sizeof(OS2CodePage), OS2CodePage, &OS2CodePageLen ) )
4661 asprintf(&OS2CodePageStr, "SYSTEM");
4662 else
4663 asprintf(&OS2CodePageStr, "IBM-%u", OS2CodePage[0]);
4664#endif
4665
4666#ifndef __OS2__
4667 /* using UTF8 by default allows us to support all chars */
4668 string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
4669#else
4670 /* On OS/2, using UTF8 causes problems with display of foreign
4671 characters - default to system codepage */
4672 string_set(&Globals.unix_charset, OS2CodePageStr);
4673#endif
4674
4675#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
4676 /* If the system supports nl_langinfo(), try to grab the value
4677 from the user's locale */
4678#ifndef __OS2__
4679 /* this does somehow not work on OS/2 */
4680 string_set(&Globals.display_charset, "LOCALE");
4681#else
4682 /* On OS/2, using UTF8 causes problems with display of foreign
4683 characters - default to system codepage */
4684 string_set(&Globals.display_charset, OS2CodePageStr);
4685#endif
4686
4687#else
4688 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
4689#endif
4690
4691#ifndef __OS2__
4692 /* Use codepage 850 as a default for the dos character set */
4693 string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
4694#else
4695 /* On OS/2, using UTF8 causes problems with display of foreign
4696 characters - default to system codepage */
4697 string_set(&Globals.dos_charset, OS2CodePageStr);
4698#endif
4699
4700 /*
4701 * Allow the default PASSWD_CHAT to be overridden in local.h.
4702 */
4703 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
4704
4705 set_global_myname(myhostname());
4706 string_set(&Globals.szNetbiosName,global_myname());
4707
4708 set_global_myworkgroup(WORKGROUP);
4709 string_set(&Globals.szWorkgroup, lp_workgroup());
4710
4711 string_set(&Globals.szPasswdProgram, "");
4712 string_set(&Globals.szPidDir, get_dyn_PIDDIR());
4713 string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
4714#ifdef __OS2__
4715 newLockDir = True;
4716#endif
4717 string_set(&Globals.szSocketAddress, "0.0.0.0");
4718
4719 if (asprintf(&s, "Samba %s", SAMBA_VERSION_STRING) < 0) {
4720 smb_panic("init_globals: ENOMEM");
4721 }
4722 string_set(&Globals.szServerString, s);
4723 SAFE_FREE(s);
4724 if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
4725 DEFAULT_MINOR_VERSION) < 0) {
4726 smb_panic("init_globals: ENOMEM");
4727 }
4728 string_set(&Globals.szAnnounceVersion, s);
4729 SAFE_FREE(s);
4730#ifdef DEVELOPER
4731 string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
4732#endif
4733
4734 string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
4735
4736 string_set(&Globals.szLogonDrive, "");
4737 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
4738 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
4739 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
4740
4741 string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
4742 string_set(&Globals.szPasswordServer, "*");
4743
4744 Globals.AlgorithmicRidBase = BASE_RID;
4745
4746 Globals.bLoadPrinters = True;
4747 Globals.PrintcapCacheTime = 750; /* 12.5 minutes */
4748
4749 Globals.ConfigBackend = config_backend;
4750
4751 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
4752 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
4753 Globals.max_xmit = 0x4104;
4754 Globals.max_mux = 50; /* This is *needed* for profile support. */
4755 Globals.lpqcachetime = 30; /* changed to handle large print servers better -- jerry */
4756 Globals.bDisableSpoolss = False;
4757 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
4758 Globals.pwordlevel = 0;
4759 Globals.unamelevel = 0;
4760 Globals.deadtime = 0;
4761 Globals.getwd_cache = true;
4762 Globals.bLargeReadwrite = True;
4763 Globals.max_log_size = 5000;
4764 Globals.max_open_files = MAX_OPEN_FILES;
4765 Globals.open_files_db_hash_size = SMB_OPEN_DATABASE_TDB_HASH_SIZE;
4766 Globals.maxprotocol = PROTOCOL_NT1;
4767 Globals.minprotocol = PROTOCOL_CORE;
4768 Globals.security = SEC_USER;
4769 Globals.paranoid_server_security = True;
4770 Globals.bEncryptPasswords = True;
4771 Globals.bUpdateEncrypt = False;
4772 Globals.clientSchannel = Auto;
4773 Globals.serverSchannel = Auto;
4774 Globals.bReadRaw = True;
4775 Globals.bWriteRaw = True;
4776 Globals.bNullPasswords = False;
4777 Globals.bObeyPamRestrictions = False;
4778 Globals.syslog = 1;
4779 Globals.bSyslogOnly = False;
4780 Globals.bTimestampLogs = True;
4781 string_set(&Globals.szLogLevel, "0");
4782 Globals.bDebugPrefixTimestamp = False;
4783 Globals.bDebugHiresTimestamp = False;
4784 Globals.bDebugPid = False;
4785 Globals.bDebugUid = False;
4786 Globals.bDebugClass = False;
4787 Globals.bEnableCoreFiles = True;
4788 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
4789 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
4790 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
4791 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
4792 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
4793 Globals.lm_interval = 60;
4794 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
4795#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
4796 Globals.bNISHomeMap = False;
4797#ifdef WITH_NISPLUS_HOME
4798 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
4799#else
4800 string_set(&Globals.szNISHomeMapName, "auto.home");
4801#endif
4802#endif
4803 Globals.bTimeServer = False;
4804 Globals.bBindInterfacesOnly = False;
4805 Globals.bUnixPasswdSync = False;
4806 Globals.bPamPasswordChange = False;
4807 Globals.bPasswdChatDebug = False;
4808 Globals.iPasswdChatTimeout = 2; /* 2 second default. */
4809 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
4810 Globals.bNTStatusSupport = True; /* Use NT status by default. */
4811 Globals.bStatCache = True; /* use stat cache by default */
4812 Globals.iMaxStatCacheSize = 256; /* 256k by default */
4813 Globals.restrict_anonymous = 0;
4814 Globals.bClientLanManAuth = False; /* Do NOT use the LanMan hash if it is available */
4815 Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */
4816 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */
4817 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
4818 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
4819 /* Note, that we will use NTLM2 session security (which is different), if it is available */
4820
4821 Globals.map_to_guest = 0; /* By Default, "Never" */
4822 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
4823 Globals.enhanced_browsing = true;
4824 Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
4825#ifdef MMAP_BLACKLIST
4826 Globals.bUseMmap = False;
4827#else
4828 Globals.bUseMmap = True;
4829#endif
4830 Globals.bUnixExtensions = True;
4831 Globals.bResetOnZeroVC = False;
4832
4833 /* hostname lookups can be very expensive and are broken on
4834 a large number of sites (tridge) */
4835 Globals.bHostnameLookups = False;
4836
4837 string_set(&Globals.szPassdbBackend, "smbpasswd");
4838 string_set(&Globals.szLdapSuffix, "");
4839 string_set(&Globals.szLdapMachineSuffix, "");
4840 string_set(&Globals.szLdapUserSuffix, "");
4841 string_set(&Globals.szLdapGroupSuffix, "");
4842 string_set(&Globals.szLdapIdmapSuffix, "");
4843
4844 string_set(&Globals.szLdapAdminDn, "");
4845 Globals.ldap_ssl = LDAP_SSL_START_TLS;
4846 Globals.ldap_ssl_ads = False;
4847 Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
4848 Globals.ldap_delete_dn = False;
4849 Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */
4850 Globals.ldap_timeout = LDAP_DEFAULT_TIMEOUT;
4851 Globals.ldap_connection_timeout = LDAP_CONNECTION_DEFAULT_TIMEOUT;
4852 Globals.ldap_page_size = LDAP_PAGE_SIZE;
4853
4854 Globals.ldap_debug_level = 0;
4855 Globals.ldap_debug_threshold = 10;
4856
4857 /* This is what we tell the afs client. in reality we set the token
4858 * to never expire, though, when this runs out the afs client will
4859 * forget the token. Set to 0 to get NEVERDATE.*/
4860 Globals.iAfsTokenLifetime = 604800;
4861 Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT;
4862
4863/* these parameters are set to defaults that are more appropriate
4864 for the increasing samba install base:
4865
4866 as a member of the workgroup, that will possibly become a
4867 _local_ master browser (lm = True). this is opposed to a forced
4868 local master browser startup (pm = True).
4869
4870 doesn't provide WINS server service by default (wsupp = False),
4871 and doesn't provide domain master browser services by default, either.
4872
4873*/
4874
4875 Globals.bMsAddPrinterWizard = True;
4876 Globals.os_level = 20;
4877 Globals.bLocalMaster = True;
4878 Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
4879 Globals.bDomainLogons = False;
4880 Globals.bBrowseList = True;
4881 Globals.bWINSsupport = False;
4882 Globals.bWINSproxy = False;
4883
4884 TALLOC_FREE(Globals.szInitLogonDelayedHosts);
4885 Globals.InitLogonDelay = 100; /* 100 ms default delay */
4886
4887 Globals.bDNSproxy = True;
4888
4889 /* this just means to use them if they exist */
4890 Globals.bKernelOplocks = True;
4891
4892 Globals.bAllowTrustedDomains = True;
4893 string_set(&Globals.szIdmapBackend, "tdb");
4894
4895 string_set(&Globals.szTemplateShell, "/bin/false");
4896 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
4897 string_set(&Globals.szWinbindSeparator, "\\");
4898
4899 string_set(&Globals.szCupsServer, "");
4900 string_set(&Globals.szIPrintServer, "");
4901
4902 string_set(&Globals.ctdbdSocket, "");
4903 Globals.szClusterAddresses = NULL;
4904 Globals.clustering = False;
4905
4906 Globals.winbind_cache_time = 300; /* 5 minutes */
4907 Globals.winbind_reconnect_delay = 30; /* 30 seconds */
4908 Globals.bWinbindEnumUsers = False;
4909 Globals.bWinbindEnumGroups = False;
4910 Globals.bWinbindUseDefaultDomain = False;
4911 Globals.bWinbindTrustedDomainsOnly = False;
4912 Globals.bWinbindNestedGroups = True;
4913 Globals.winbind_expand_groups = 1;
4914 Globals.szWinbindNssInfo = str_list_make(talloc_autofree_context(), "template", NULL);
4915 Globals.bWinbindRefreshTickets = False;
4916 Globals.bWinbindOfflineLogon = False;
4917
4918 Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */
4919 Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
4920
4921 Globals.bPassdbExpandExplicit = False;
4922
4923 Globals.name_cache_timeout = 660; /* In seconds */
4924
4925 Globals.bUseSpnego = True;
4926 Globals.bClientUseSpnego = True;
4927
4928 Globals.client_signing = Auto;
4929 Globals.server_signing = False;
4930
4931 Globals.bDeferSharingViolations = True;
4932 string_set(&Globals.smb_ports, SMB_PORTS);
4933
4934 Globals.bEnablePrivileges = True;
4935 Globals.bHostMSDfs = True;
4936 Globals.bASUSupport = False;
4937
4938 /* User defined shares. */
4939 if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
4940 smb_panic("init_globals: ENOMEM");
4941 }
4942 string_set(&Globals.szUsersharePath, s);
4943 SAFE_FREE(s);
4944 string_set(&Globals.szUsershareTemplateShare, "");
4945 Globals.iUsershareMaxShares = 0;
4946 /* By default disallow sharing of directories not owned by the sharer. */
4947 Globals.bUsershareOwnerOnly = True;
4948 /* By default disallow guest access to usershares. */
4949 Globals.bUsershareAllowGuests = False;
4950
4951 Globals.iKeepalive = DEFAULT_KEEPALIVE;
4952
4953 /* By default no shares out of the registry */
4954 Globals.bRegistryShares = False;
4955
4956 Globals.iminreceivefile = 0;
4957}
4958
4959/*******************************************************************
4960 Convenience routine to grab string parameters into temporary memory
4961 and run standard_sub_basic on them. The buffers can be written to by
4962 callers without affecting the source string.
4963********************************************************************/
4964
4965static char *lp_string(const char *s)
4966{
4967 char *ret;
4968 TALLOC_CTX *ctx = talloc_tos();
4969
4970 /* The follow debug is useful for tracking down memory problems
4971 especially if you have an inner loop that is calling a lp_*()
4972 function that returns a string. Perhaps this debug should be
4973 present all the time? */
4974
4975#if 0
4976 DEBUG(10, ("lp_string(%s)\n", s));
4977#endif
4978
4979 ret = talloc_sub_basic(ctx,
4980 get_current_username(),
4981 current_user_info.domain,
4982 s);
4983 if (trim_char(ret, '\"', '\"')) {
4984 if (strchr(ret,'\"') != NULL) {
4985 TALLOC_FREE(ret);
4986 ret = talloc_sub_basic(ctx,
4987 get_current_username(),
4988 current_user_info.domain,
4989 s);
4990 }
4991 }
4992 return ret;
4993}
4994
4995/*
4996 In this section all the functions that are used to access the
4997 parameters from the rest of the program are defined
4998*/
4999
5000#define FN_GLOBAL_STRING(fn_name,ptr) \
5001 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
5002#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
5003 const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
5004#define FN_GLOBAL_LIST(fn_name,ptr) \
5005 const char **fn_name(void) {return(*(const char ***)(ptr));}
5006#define FN_GLOBAL_BOOL(fn_name,ptr) \
5007 bool fn_name(void) {return(*(bool *)(ptr));}
5008#define FN_GLOBAL_CHAR(fn_name,ptr) \
5009 char fn_name(void) {return(*(char *)(ptr));}
5010#define FN_GLOBAL_INTEGER(fn_name,ptr) \
5011 int fn_name(void) {return(*(int *)(ptr));}
5012
5013#define FN_LOCAL_STRING(fn_name,val) \
5014 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
5015#define FN_LOCAL_CONST_STRING(fn_name,val) \
5016 const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
5017#define FN_LOCAL_LIST(fn_name,val) \
5018 const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5019#define FN_LOCAL_BOOL(fn_name,val) \
5020 bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5021#define FN_LOCAL_INTEGER(fn_name,val) \
5022 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
5023
5024#define FN_LOCAL_PARM_BOOL(fn_name,val) \
5025 bool fn_name(const struct share_params *p) {return(bool)(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5026#define FN_LOCAL_PARM_INTEGER(fn_name,val) \
5027 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5028#define FN_LOCAL_PARM_STRING(fn_name,val) \
5029 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));}
5030#define FN_LOCAL_CHAR(fn_name,val) \
5031 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
5032
5033FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
5034FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
5035FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
5036FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
5037FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
5038FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
5039FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
5040FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
5041FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
5042FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
5043FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
5044FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
5045FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
5046FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
5047FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
5048FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
5049FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
5050FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
5051FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
5052FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
5053FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
5054FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
5055FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
5056FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
5057FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
5058FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
5059FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
5060FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
5061FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
5062FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
5063FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
5064FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
5065FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
5066FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
5067FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
5068FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
5069FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
5070FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
5071FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
5072FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
5073FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
5074FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
5075FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
5076FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
5077FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
5078FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
5079static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
5080FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
5081/* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
5082 * lp_passdb_backend() should be replace by the this macro again after
5083 * some releases.
5084 * */
5085const char *lp_passdb_backend(void)
5086{
5087 char *delim, *quote;
5088
5089 delim = strchr( Globals.szPassdbBackend, ' ');
5090 /* no space at all */
5091 if (delim == NULL) {
5092 goto out;
5093 }
5094
5095 quote = strchr(Globals.szPassdbBackend, '"');
5096 /* no quote char or non in the first part */
5097 if (quote == NULL || quote > delim) {
5098 *delim = '\0';
5099 goto warn;
5100 }
5101
5102 quote = strchr(quote+1, '"');
5103 if (quote == NULL) {
5104 DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
5105 goto out;
5106 } else if (*(quote+1) == '\0') {
5107 /* space, fitting quote char, and one backend only */
5108 goto out;
5109 } else {
5110 /* terminate string after the fitting quote char */
5111 *(quote+1) = '\0';
5112 }
5113
5114warn:
5115 DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends. This\n"
5116 "is deprecated since Samba 3.0.23. Please check WHATSNEW.txt or the section 'Passdb\n"
5117 "Changes' from the ChangeNotes as part of the Samba HOWTO collection. Only the first\n"
5118 "backend (%s) is used. The rest is ignored.\n", Globals.szPassdbBackend));
5119
5120out:
5121 return Globals.szPassdbBackend;
5122}
5123FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
5124FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
5125FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
5126FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
5127FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
5128
5129FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
5130FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
5131FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
5132FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
5133FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
5134FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
5135
5136FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
5137
5138FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
5139FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
5140FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
5141
5142FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
5143
5144FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
5145FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
5146FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
5147FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
5148FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
5149FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
5150FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
5151FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
5152FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
5153FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
5154FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
5155FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
5156FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
5157FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
5158FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
5159
5160FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
5161FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
5162FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
5163FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
5164FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
5165FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
5166
5167FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
5168FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
5169FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
5170FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
5171FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
5172FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
5173FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
5174FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
5175FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
5176FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
5177FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
5178FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
5179FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
5180FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
5181FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
5182FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
5183FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
5184FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
5185
5186FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
5187
5188FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
5189FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
5190FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
5191FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
5192FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
5193FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
5194FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
5195FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
5196FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
5197FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
5198FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
5199FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
5200FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
5201FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
5202FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
5203FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
5204FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
5205FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
5206FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
5207FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
5208FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
5209FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
5210FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
5211FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
5212FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
5213FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
5214FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
5215FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
5216FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
5217FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
5218FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
5219FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
5220FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
5221FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
5222static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
5223FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
5224FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
5225FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
5226FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
5227FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
5228FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
5229FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
5230FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
5231FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
5232FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
5233FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
5234FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
5235FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
5236FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
5237FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
5238FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
5239FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
5240FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
5241FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
5242FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
5243FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
5244FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
5245FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
5246FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
5247FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
5248FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
5249FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab)
5250FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
5251FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
5252FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
5253FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
5254FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
5255FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
5256FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
5257FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
5258FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
5259FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
5260FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
5261FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
5262FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
5263FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
5264FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
5265FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
5266FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
5267FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
5268FN_GLOBAL_INTEGER(lp_security, &Globals.security)
5269FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
5270FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
5271FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
5272FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
5273FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
5274FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
5275FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
5276static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
5277FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
5278FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
5279FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
5280FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
5281FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
5282FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
5283FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
5284FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
5285FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
5286
5287FN_LOCAL_STRING(lp_preexec, szPreExec)
5288FN_LOCAL_STRING(lp_postexec, szPostExec)
5289FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
5290FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
5291FN_LOCAL_STRING(lp_servicename, szService)
5292FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
5293FN_LOCAL_STRING(lp_pathname, szPath)
5294FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
5295FN_LOCAL_STRING(lp_username, szUsername)
5296FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
5297FN_LOCAL_LIST(lp_valid_users, szValidUsers)
5298FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
5299FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
5300FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
5301FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
5302FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
5303FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
5304FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
5305FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
5306FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
5307FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
5308FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
5309FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
5310FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
5311FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
5312FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
5313FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
5314static FN_LOCAL_STRING(_lp_printername, szPrintername)
5315FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
5316FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
5317FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
5318FN_LOCAL_STRING(lp_magicscript, szMagicScript)
5319FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
5320FN_LOCAL_STRING(lp_comment, comment)
5321FN_LOCAL_STRING(lp_force_user, force_user)
5322FN_LOCAL_STRING(lp_force_group, force_group)
5323FN_LOCAL_LIST(lp_readlist, readlist)
5324FN_LOCAL_LIST(lp_writelist, writelist)
5325FN_LOCAL_LIST(lp_printer_admin, printer_admin)
5326FN_LOCAL_STRING(lp_fstype, fstype)
5327FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
5328FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
5329static FN_LOCAL_STRING(lp_volume, volume)
5330FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
5331FN_LOCAL_STRING(lp_hide_files, szHideFiles)
5332FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
5333FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
5334FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
5335FN_LOCAL_STRING(lp_dfree_command, szDfree)
5336FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
5337FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
5338FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
5339FN_LOCAL_INTEGER(lp_casesensitive, iCaseSensitive)
5340FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
5341FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
5342FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
5343FN_LOCAL_BOOL(lp_hide_special_files, bHideSpecialFiles)
5344FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
5345FN_LOCAL_BOOL(lp_hideunwriteable_files, bHideUnWriteableFiles)
5346FN_LOCAL_BOOL(lp_browseable, bBrowseable)
5347FN_LOCAL_BOOL(lp_readonly, bRead_only)
5348FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
5349FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
5350FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
5351FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
5352FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
5353FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
5354FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
5355FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
5356FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
5357FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
5358FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
5359FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
5360FN_LOCAL_BOOL(lp_share_modes, bShareModes)
5361FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
5362FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
5363FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
5364FN_LOCAL_PARM_BOOL(lp_manglednames, bMangledNames)
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#ifdef __OS2__
8980 if (lp_is_in_client() && newLockDir) {
8981 char* s=NULL;
8982 if (asprintf(&s, "%s/%s", lp_lockdir(), "client") < 0) {
8983 smb_panic("init_globals: ENOMEM");
8984 }
8985 lp_do_parameter(GLOBAL_SECTION_SNUM, "lock directory", s);
8986 SAFE_FREE(s);
8987 newLockDir = False;
8988 }
8989#endif
8990
8991 init_iconv();
8992
8993 bAllowIncludeRegistry = true;
8994
8995 return (bRetval);
8996}
8997
8998bool lp_load(const char *pszFname,
8999 bool global_only,
9000 bool save_defaults,
9001 bool add_ipc,
9002 bool initialize_globals)
9003{
9004 return lp_load_ex(pszFname,
9005 global_only,
9006 save_defaults,
9007 add_ipc,
9008 initialize_globals,
9009 true, false);
9010}
9011
9012bool lp_load_initial_only(const char *pszFname)
9013{
9014 return lp_load_ex(pszFname,
9015 true,
9016 false,
9017 false,
9018 true,
9019 false,
9020 false);
9021}
9022
9023bool lp_load_with_registry_shares(const char *pszFname,
9024 bool global_only,
9025 bool save_defaults,
9026 bool add_ipc,
9027 bool initialize_globals)
9028{
9029 return lp_load_ex(pszFname,
9030 global_only,
9031 save_defaults,
9032 add_ipc,
9033 initialize_globals,
9034 true,
9035 true);
9036}
9037
9038/***************************************************************************
9039 Return the max number of services.
9040***************************************************************************/
9041
9042int lp_numservices(void)
9043{
9044 return (iNumServices);
9045}
9046
9047/***************************************************************************
9048Display the contents of the services array in human-readable form.
9049***************************************************************************/
9050
9051void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
9052{
9053 int iService;
9054
9055 if (show_defaults)
9056 defaults_saved = False;
9057
9058 dump_globals(f);
9059
9060 dump_a_service(&sDefault, f);
9061
9062 for (iService = 0; iService < maxtoprint; iService++) {
9063 fprintf(f,"\n");
9064 lp_dump_one(f, show_defaults, iService);
9065 }
9066}
9067
9068/***************************************************************************
9069Display the contents of one service in human-readable form.
9070***************************************************************************/
9071
9072void lp_dump_one(FILE * f, bool show_defaults, int snum)
9073{
9074 if (VALID(snum)) {
9075 if (ServicePtrs[snum]->szService[0] == '\0')
9076 return;
9077 dump_a_service(ServicePtrs[snum], f);
9078 }
9079}
9080
9081/***************************************************************************
9082Return the number of the service with the given name, or -1 if it doesn't
9083exist. Note that this is a DIFFERENT ANIMAL from the internal function
9084getservicebyname()! This works ONLY if all services have been loaded, and
9085does not copy the found service.
9086***************************************************************************/
9087
9088int lp_servicenumber(const char *pszServiceName)
9089{
9090 int iService;
9091 fstring serviceName;
9092
9093 if (!pszServiceName) {
9094 return GLOBAL_SECTION_SNUM;
9095 }
9096
9097 for (iService = iNumServices - 1; iService >= 0; iService--) {
9098 if (VALID(iService) && ServicePtrs[iService]->szService) {
9099 /*
9100 * The substitution here is used to support %U is
9101 * service names
9102 */
9103 fstrcpy(serviceName, ServicePtrs[iService]->szService);
9104 standard_sub_basic(get_current_username(),
9105 current_user_info.domain,
9106 serviceName,sizeof(serviceName));
9107 if (strequal(serviceName, pszServiceName)) {
9108 break;
9109 }
9110 }
9111 }
9112
9113 if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
9114 time_t last_mod;
9115
9116 if (!usershare_exists(iService, &last_mod)) {
9117 /* Remove the share security tdb entry for it. */
9118 delete_share_security(lp_servicename(iService));
9119 /* Remove it from the array. */
9120 free_service_byindex(iService);
9121 /* Doesn't exist anymore. */
9122 return GLOBAL_SECTION_SNUM;
9123 }
9124
9125 /* Has it been modified ? If so delete and reload. */
9126 if (ServicePtrs[iService]->usershare_last_mod < last_mod) {
9127 /* Remove it from the array. */
9128 free_service_byindex(iService);
9129 /* and now reload it. */
9130 iService = load_usershare_service(pszServiceName);
9131 }
9132 }
9133
9134 if (iService < 0) {
9135 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
9136 return GLOBAL_SECTION_SNUM;
9137 }
9138
9139 return (iService);
9140}
9141
9142bool share_defined(const char *service_name)
9143{
9144 return (lp_servicenumber(service_name) != -1);
9145}
9146
9147struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
9148 const char *sharename)
9149{
9150 struct share_params *result;
9151 char *sname;
9152 int snum;
9153
9154 if (!(sname = SMB_STRDUP(sharename))) {
9155 return NULL;
9156 }
9157
9158 snum = find_service(sname);
9159 SAFE_FREE(sname);
9160
9161 if (snum < 0) {
9162 return NULL;
9163 }
9164
9165 if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
9166 DEBUG(0, ("talloc failed\n"));
9167 return NULL;
9168 }
9169
9170 result->service = snum;
9171 return result;
9172}
9173
9174struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
9175{
9176 struct share_iterator *result;
9177
9178 if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
9179 DEBUG(0, ("talloc failed\n"));
9180 return NULL;
9181 }
9182
9183 result->next_id = 0;
9184 return result;
9185}
9186
9187struct share_params *next_share(struct share_iterator *list)
9188{
9189 struct share_params *result;
9190
9191 while (!lp_snum_ok(list->next_id) &&
9192 (list->next_id < lp_numservices())) {
9193 list->next_id += 1;
9194 }
9195
9196 if (list->next_id >= lp_numservices()) {
9197 return NULL;
9198 }
9199
9200 if (!(result = TALLOC_P(list, struct share_params))) {
9201 DEBUG(0, ("talloc failed\n"));
9202 return NULL;
9203 }
9204
9205 result->service = list->next_id;
9206 list->next_id += 1;
9207 return result;
9208}
9209
9210struct share_params *next_printer(struct share_iterator *list)
9211{
9212 struct share_params *result;
9213
9214 while ((result = next_share(list)) != NULL) {
9215 if (lp_print_ok(result->service)) {
9216 break;
9217 }
9218 }
9219 return result;
9220}
9221
9222/*
9223 * This is a hack for a transition period until we transformed all code from
9224 * service numbers to struct share_params.
9225 */
9226
9227struct share_params *snum2params_static(int snum)
9228{
9229 static struct share_params result;
9230 result.service = snum;
9231 return &result;
9232}
9233
9234/*******************************************************************
9235 A useful volume label function.
9236********************************************************************/
9237
9238const char *volume_label(int snum)
9239{
9240 char *ret;
9241 const char *label = lp_volume(snum);
9242 if (!*label) {
9243 label = lp_servicename(snum);
9244 }
9245
9246 /* This returns a 33 byte guarenteed null terminated string. */
9247 ret = talloc_strndup(talloc_tos(), label, 32);
9248 if (!ret) {
9249 return "";
9250 }
9251 return ret;
9252}
9253
9254/*******************************************************************
9255 Set the server type we will announce as via nmbd.
9256********************************************************************/
9257
9258static void set_default_server_announce_type(void)
9259{
9260 default_server_announce = 0;
9261 default_server_announce |= SV_TYPE_WORKSTATION;
9262 default_server_announce |= SV_TYPE_SERVER;
9263 default_server_announce |= SV_TYPE_SERVER_UNIX;
9264
9265 /* note that the flag should be set only if we have a
9266 printer service but nmbd doesn't actually load the
9267 services so we can't tell --jerry */
9268
9269 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
9270
9271 switch (lp_announce_as()) {
9272 case ANNOUNCE_AS_NT_SERVER:
9273 default_server_announce |= SV_TYPE_SERVER_NT;
9274 /* fall through... */
9275 case ANNOUNCE_AS_NT_WORKSTATION:
9276 default_server_announce |= SV_TYPE_NT;
9277 break;
9278 case ANNOUNCE_AS_WIN95:
9279 default_server_announce |= SV_TYPE_WIN95_PLUS;
9280 break;
9281 case ANNOUNCE_AS_WFW:
9282 default_server_announce |= SV_TYPE_WFW;
9283 break;
9284 default:
9285 break;
9286 }
9287
9288 switch (lp_server_role()) {
9289 case ROLE_DOMAIN_MEMBER:
9290 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
9291 break;
9292 case ROLE_DOMAIN_PDC:
9293 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
9294 break;
9295 case ROLE_DOMAIN_BDC:
9296 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
9297 break;
9298 case ROLE_STANDALONE:
9299 default:
9300 break;
9301 }
9302 if (lp_time_server())
9303 default_server_announce |= SV_TYPE_TIME_SOURCE;
9304
9305 if (lp_host_msdfs())
9306 default_server_announce |= SV_TYPE_DFS_SERVER;
9307}
9308
9309/***********************************************************
9310 returns role of Samba server
9311************************************************************/
9312
9313int lp_server_role(void)
9314{
9315 return server_role;
9316}
9317
9318/***********************************************************
9319 If we are PDC then prefer us as DMB
9320************************************************************/
9321
9322bool lp_domain_master(void)
9323{
9324 if (Globals.iDomainMaster == Auto)
9325 return (lp_server_role() == ROLE_DOMAIN_PDC);
9326
9327 return (bool)Globals.iDomainMaster;
9328}
9329
9330/***********************************************************
9331 If we are DMB then prefer us as LMB
9332************************************************************/
9333
9334bool lp_preferred_master(void)
9335{
9336 if (Globals.iPreferredMaster == Auto)
9337 return (lp_local_master() && lp_domain_master());
9338
9339 return (bool)Globals.iPreferredMaster;
9340}
9341
9342/*******************************************************************
9343 Remove a service.
9344********************************************************************/
9345
9346void lp_remove_service(int snum)
9347{
9348 ServicePtrs[snum]->valid = False;
9349 invalid_services[num_invalid_services++] = snum;
9350}
9351
9352/*******************************************************************
9353 Copy a service.
9354********************************************************************/
9355
9356void lp_copy_service(int snum, const char *new_name)
9357{
9358 do_section(new_name, NULL);
9359 if (snum >= 0) {
9360 snum = lp_servicenumber(new_name);
9361 if (snum >= 0)
9362 lp_do_parameter(snum, "copy", lp_servicename(snum));
9363 }
9364}
9365
9366
9367/*******************************************************************
9368 Get the default server type we will announce as via nmbd.
9369********************************************************************/
9370
9371int lp_default_server_announce(void)
9372{
9373 return default_server_announce;
9374}
9375
9376/*******************************************************************
9377 Split the announce version into major and minor numbers.
9378********************************************************************/
9379
9380int lp_major_announce_version(void)
9381{
9382 static bool got_major = False;
9383 static int major_version = DEFAULT_MAJOR_VERSION;
9384 char *vers;
9385 char *p;
9386
9387 if (got_major)
9388 return major_version;
9389
9390 got_major = True;
9391 if ((vers = lp_announce_version()) == NULL)
9392 return major_version;
9393
9394 if ((p = strchr_m(vers, '.')) == 0)
9395 return major_version;
9396
9397 *p = '\0';
9398 major_version = atoi(vers);
9399 return major_version;
9400}
9401
9402int lp_minor_announce_version(void)
9403{
9404 static bool got_minor = False;
9405 static int minor_version = DEFAULT_MINOR_VERSION;
9406 char *vers;
9407 char *p;
9408
9409 if (got_minor)
9410 return minor_version;
9411
9412 got_minor = True;
9413 if ((vers = lp_announce_version()) == NULL)
9414 return minor_version;
9415
9416 if ((p = strchr_m(vers, '.')) == 0)
9417 return minor_version;
9418
9419 p++;
9420 minor_version = atoi(p);
9421 return minor_version;
9422}
9423
9424/***********************************************************
9425 Set the global name resolution order (used in smbclient).
9426************************************************************/
9427
9428void lp_set_name_resolve_order(const char *new_order)
9429{
9430 string_set(&Globals.szNameResolveOrder, new_order);
9431}
9432
9433const char *lp_printername(int snum)
9434{
9435 const char *ret = _lp_printername(snum);
9436 if (ret == NULL || (ret != NULL && *ret == '\0'))
9437 ret = lp_const_servicename(snum);
9438
9439 return ret;
9440}
9441
9442
9443/***********************************************************
9444 Allow daemons such as winbindd to fix their logfile name.
9445************************************************************/
9446
9447void lp_set_logfile(const char *name)
9448{
9449 string_set(&Globals.szLogFile, name);
9450 debug_set_logfile(name);
9451}
9452
9453/*******************************************************************
9454 Return the max print jobs per queue.
9455********************************************************************/
9456
9457int lp_maxprintjobs(int snum)
9458{
9459 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
9460 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
9461 maxjobs = PRINT_MAX_JOBID - 1;
9462
9463 return maxjobs;
9464}
9465
9466const char *lp_printcapname(void)
9467{
9468 if ((Globals.szPrintcapname != NULL) &&
9469 (Globals.szPrintcapname[0] != '\0'))
9470 return Globals.szPrintcapname;
9471
9472 if (sDefault.iPrinting == PRINT_CUPS) {
9473#ifdef HAVE_CUPS
9474 return "cups";
9475#else
9476 return "lpstat";
9477#endif
9478 }
9479
9480 if (sDefault.iPrinting == PRINT_BSD)
9481 return "/etc/printcap";
9482
9483 return PRINTCAP_NAME;
9484}
9485
9486/*******************************************************************
9487 Ensure we don't use sendfile if server smb signing is active.
9488********************************************************************/
9489
9490static uint32 spoolss_state;
9491
9492bool lp_disable_spoolss( void )
9493{
9494 if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
9495 spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9496
9497 return spoolss_state == SVCCTL_STOPPED ? True : False;
9498}
9499
9500void lp_set_spoolss_state( uint32 state )
9501{
9502 SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
9503
9504 spoolss_state = state;
9505}
9506
9507uint32 lp_get_spoolss_state( void )
9508{
9509 return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
9510}
9511
9512/*******************************************************************
9513 Ensure we don't use sendfile if server smb signing is active.
9514********************************************************************/
9515
9516bool lp_use_sendfile(int snum)
9517{
9518 /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
9519 if (Protocol < PROTOCOL_NT1) {
9520 return False;
9521 }
9522 return (_lp_use_sendfile(snum) &&
9523 (get_remote_arch() != RA_WIN95) &&
9524 !srv_is_signing_active());
9525}
9526
9527/*******************************************************************
9528 Turn off sendfile if we find the underlying OS doesn't support it.
9529********************************************************************/
9530
9531void set_use_sendfile(int snum, bool val)
9532{
9533 if (LP_SNUM_OK(snum))
9534 ServicePtrs[snum]->bUseSendfile = val;
9535 else
9536 sDefault.bUseSendfile = val;
9537}
9538
9539/*******************************************************************
9540 Turn off storing DOS attributes if this share doesn't support it.
9541********************************************************************/
9542
9543void set_store_dos_attributes(int snum, bool val)
9544{
9545 if (!LP_SNUM_OK(snum))
9546 return;
9547 ServicePtrs[(snum)]->bStoreDosAttributes = val;
9548}
9549
9550void lp_set_mangling_method(const char *new_method)
9551{
9552 string_set(&Globals.szManglingMethod, new_method);
9553}
9554
9555/*******************************************************************
9556 Global state for POSIX pathname processing.
9557********************************************************************/
9558
9559static bool posix_pathnames;
9560
9561bool lp_posix_pathnames(void)
9562{
9563 return posix_pathnames;
9564}
9565
9566/*******************************************************************
9567 Change everything needed to ensure POSIX pathname processing (currently
9568 not much).
9569********************************************************************/
9570
9571void lp_set_posix_pathnames(void)
9572{
9573 posix_pathnames = True;
9574}
9575
9576/*******************************************************************
9577 Global state for POSIX lock processing - CIFS unix extensions.
9578********************************************************************/
9579
9580bool posix_default_lock_was_set;
9581static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
9582
9583enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
9584{
9585 if (posix_default_lock_was_set) {
9586 return posix_cifsx_locktype;
9587 } else {
9588 return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
9589 }
9590}
9591
9592/*******************************************************************
9593********************************************************************/
9594
9595void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
9596{
9597 posix_default_lock_was_set = True;
9598 posix_cifsx_locktype = val;
9599}
9600
9601int lp_min_receive_file_size(void)
9602{
9603 if (Globals.iminreceivefile < 0) {
9604 return 0;
9605 }
9606 return MIN(Globals.iminreceivefile, BUFFER_SIZE);
9607}
9608
9609/*******************************************************************
9610 If socket address is an empty character string, it is necessary to
9611 define it as "0.0.0.0".
9612********************************************************************/
9613
9614const char *lp_socket_address(void)
9615{
9616 char *sock_addr = Globals.szSocketAddress;
9617
9618 if (sock_addr[0] == '\0'){
9619 string_set(&Globals.szSocketAddress, "0.0.0.0");
9620 }
9621 return Globals.szSocketAddress;
9622}
9623
9624/*******************************************************************
9625 Safe wide links checks.
9626 This helper function always verify the validity of wide links,
9627 even after a configuration file reload.
9628********************************************************************/
9629
9630static bool lp_widelinks_internal(int snum)
9631{
9632 return (bool)(LP_SNUM_OK(snum)? ServicePtrs[(snum)]->bWidelinks :
9633 sDefault.bWidelinks);
9634}
9635
9636void widelinks_warning(int snum)
9637{
9638 if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
9639 DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
9640 "These parameters are incompatible. "
9641 "Wide links will be disabled for this share.\n",
9642 lp_servicename(snum) ));
9643 }
9644}
9645
9646bool lp_widelinks(int snum)
9647{
9648 /* wide links is always incompatible with unix extensions */
9649 if (lp_unix_extensions()) {
9650 return false;
9651 }
9652
9653 return lp_widelinks_internal(snum);
9654}
Note: See TracBrowser for help on using the repository browser.