reverting patch back to localhost in smbd_running()
[Samba.git] / source / param / loadparm.c
blobdd183ab8af9e01d5b02b4edf6a8f183eb6440c61
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 Parameter loading functions
5 Copyright (C) Karl Auer 1993-1998
7 Largely re-written by Andrew Tridgell, September 1994
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Load parameters.
27 * This module provides suitable callback functions for the params
28 * module. It builds the internal table of service details which is
29 * then used by the rest of the server.
31 * To add a parameter:
33 * 1) add it to the global or service structure definition
34 * 2) add it to the parm_table
35 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
36 * 4) If it's a global then initialise it in init_globals. If a local
37 * (ie. service) parameter then initialise it in the sDefault structure
40 * Notes:
41 * The configuration file is processed sequentially for speed. It is NOT
42 * accessed randomly as happens in 'real' Windows. For this reason, there
43 * is a fair bit of sequence-dependent code here - ie., code which assumes
44 * that certain things happen before others. In particular, the code which
45 * happens at the boundary between sections is delicately poised, so be
46 * careful!
50 #include "includes.h"
52 /* Set default coding system for KANJI if none specified in Makefile. */
53 /*
54 * We treat KANJI specially due to historical precedent (it was the
55 * first non-english codepage added to Samba). With the new dynamic
56 * codepage support this is not needed anymore.
58 * The define 'KANJI' is being overloaded to mean 'use kanji codepage
59 * by default' and also 'this is the filename-to-disk conversion
60 * method to use'. This really should be removed and all control
61 * over this left in the smb.conf parameters 'client codepage'
62 * and 'coding system'.
64 #ifndef KANJI
65 #define KANJI "sbcs"
66 #endif /* KANJI */
68 BOOL in_client = False; /* Not in the client by default */
69 BOOL bLoaded = False;
71 extern int DEBUGLEVEL_CLASS[DBGC_LAST];
72 extern pstring user_socket_options;
73 extern pstring global_myname;
74 pstring global_scope = "";
77 #ifndef GLOBAL_NAME
78 #define GLOBAL_NAME "global"
79 #endif
81 #ifndef PRINTERS_NAME
82 #define PRINTERS_NAME "printers"
83 #endif
85 #ifndef HOMES_NAME
86 #define HOMES_NAME "homes"
87 #endif
89 /* some helpful bits */
90 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
91 #define VALID(i) ServicePtrs[i]->valid
93 int keepalive = DEFAULT_KEEPALIVE;
94 BOOL use_getwd_cache = True;
96 extern int extra_time_offset;
98 static BOOL defaults_saved = False;
101 * This structure describes global (ie., server-wide) parameters.
103 typedef struct
105 char *szPrintcapname;
106 char *szEnumPortsCommand;
107 char *szAddPrinterCommand;
108 char *szDeletePrinterCommand;
109 char *szOs2DriverMap;
110 char *szLockDir;
111 char *szPidDir;
112 char *szRootdir;
113 char *szDefaultService;
114 char *szDfree;
115 char *szMsgCommand;
116 char *szHostsEquiv;
117 char *szServerString;
118 char *szAutoServices;
119 char *szPasswdProgram;
120 char *szPasswdChat;
121 char *szLogFile;
122 char *szConfigFile;
123 #ifdef WITH_TDB_SAM
124 char *szTDBPasswdFile;
125 #else
126 char *szSMBPasswdFile;
127 #endif
128 char *szPasswordServer;
129 char *szSocketOptions;
130 char *szValidChars;
131 char *szWorkGroup;
132 char *szDomainAdminGroup;
133 char *szDomainGuestGroup;
134 char *szDomainHostsallow;
135 char *szDomainHostsdeny;
136 char *szUsernameMap;
137 #ifdef USING_GROUPNAME_MAP
138 char *szGroupnameMap;
139 #endif /* USING_GROUPNAME_MAP */
140 char *szCharacterSet;
141 char *szCodePageDir;
142 char *szLogonScript;
143 char *szLogonPath;
144 char *szLogonDrive;
145 char *szLogonHome;
146 char *szWINSserver;
147 char *szCodingSystem;
148 char *szInterfaces;
149 char *szRemoteAnnounce;
150 char *szRemoteBrowseSync;
151 char *szSocketAddress;
152 char *szNISHomeMapName;
153 char *szAnnounceVersion; /* This is initialised in init_globals */
154 char *szNetbiosAliases;
155 char *szDomainOtherSIDs;
156 char *szNameResolveOrder;
157 char *szPanicAction;
158 char *szAddUserScript;
159 char *szDelUserScript;
160 char *szWINSHook;
161 #ifdef WITH_UTMP
162 char *szUtmpDir;
163 char *szWtmpDir;
164 BOOL bUtmp;
165 #endif
166 char *szSourceEnv;
167 char *szWinbindUID;
168 char *szWinbindGID;
169 char *szTemplateHomedir;
170 char *szTemplateShell;
171 char *szWinbindSeparator;
172 BOOL bWinbindEnumUsers;
173 BOOL bWinbindEnumGroups;
174 BOOL bWinbindUseDefaultDomain;
175 char *szAddShareCommand;
176 char *szChangeShareCommand;
177 char *szDeleteShareCommand;
178 char *szManglingMethod;
179 int max_log_size;
180 int mangled_stack;
181 int max_xmit;
182 int max_mux;
183 int max_open_files;
184 int pwordlevel;
185 int unamelevel;
186 int deadtime;
187 int maxprotocol;
188 int minprotocol;
189 int security;
190 int maxdisksize;
191 int lpqcachetime;
192 int iMaxSmbdProcesses;
193 BOOL bDisableSpoolss;
194 int iTotalPrintJobs;
195 int syslog;
196 int os_level;
197 int enhanced_browsing;
198 int max_ttl;
199 int max_wins_ttl;
200 int min_wins_ttl;
201 int ReadSize;
202 int lm_announce;
203 int lm_interval;
204 int client_code_page;
205 int announce_as; /* This is initialised in init_globals */
206 int machine_password_timeout;
207 int change_notify_timeout;
208 int stat_cache_size;
209 int map_to_guest;
210 int min_passwd_length;
211 int oplock_break_wait_time;
212 int winbind_cache_time;
213 int iLockSpinCount;
214 int iLockSpinTime;
215 #ifdef WITH_LDAP_SAM
216 int ldap_port;
217 int ldap_ssl;
218 char *szLdapServer;
219 char *szLdapSuffix;
220 char *szLdapFilter;
221 char *szLdapAdminDn;
222 #endif /* WITH_LDAP */
224 #ifdef WITH_SSL
225 int sslVersion;
226 char *sslHostsRequire;
227 char *sslHostsResign;
228 char *sslCaCertDir;
229 char *sslCaCertFile;
230 char *sslServerCert;
231 char *sslServerPrivKey;
232 char *sslClientCert;
233 char *sslClientPrivKey;
234 char *sslCiphers;
235 char *sslEgdSocket;
236 char *sslEntropyFile;
237 int sslEntropyBytes;
238 BOOL sslEnabled;
239 BOOL sslReqClientCert;
240 BOOL sslReqServerCert;
241 BOOL sslCompatibility;
242 #endif /* WITH_SSL */
243 BOOL bMsAddPrinterWizard;
244 BOOL bDNSproxy;
245 BOOL bWINSsupport;
246 BOOL bWINSproxy;
247 BOOL bLocalMaster;
248 BOOL bPreferredMaster;
249 BOOL bDomainMaster;
250 BOOL bDomainLogons;
251 BOOL bEncryptPasswords;
252 BOOL bUpdateEncrypt;
253 BOOL bStripDot;
254 BOOL bNullPasswords;
255 BOOL bObeyPamRestrictions;
256 BOOL bLoadPrinters;
257 BOOL bUseRhosts;
258 BOOL bLargeReadwrite;
259 BOOL bReadRaw;
260 BOOL bWriteRaw;
261 BOOL bReadPrediction;
262 BOOL bReadbmpx;
263 BOOL bSyslogOnly;
264 BOOL bAdminLog;
265 BOOL bBrowseList;
266 BOOL bNISHomeMap;
267 BOOL bTimeServer;
268 BOOL bBindInterfacesOnly;
269 BOOL bPamPasswordChange;
270 BOOL bUnixPasswdSync;
271 BOOL bPasswdChatDebug;
272 BOOL bTimestampLogs;
273 BOOL bNTSmbSupport;
274 BOOL bNTPipeSupport;
275 BOOL bNTStatusSupport;
276 BOOL bStatCache;
277 BOOL bKernelOplocks;
278 BOOL bAllowTrustedDomains;
279 BOOL bRestrictAnonymous;
280 BOOL bLanmanAuth;
281 BOOL bDebugHiresTimestamp;
282 BOOL bDebugPid;
283 BOOL bDebugUid;
284 BOOL bHostMSDfs;
285 BOOL bHideLocalUsers;
286 BOOL bUseMmap;
287 BOOL bUnixExtensions;
288 int name_cache_timeout;
290 global;
292 static global Globals;
297 * This structure describes a single service.
299 typedef struct
301 BOOL valid;
302 BOOL autoloaded;
303 char *szService;
304 char *szPath;
305 char *szUsername;
306 char *szGuestaccount;
307 char *szInvalidUsers;
308 char *szValidUsers;
309 char *szAdminUsers;
310 char *szCopy;
311 char *szInclude;
312 char *szPreExec;
313 char *szPostExec;
314 char *szRootPreExec;
315 char *szRootPostExec;
316 char *szPrintcommand;
317 char *szLpqcommand;
318 char *szLprmcommand;
319 char *szLppausecommand;
320 char *szLpresumecommand;
321 char *szQueuepausecommand;
322 char *szQueueresumecommand;
323 char *szPrintername;
324 char *szPrinterDriver;
325 char *szPrinterDriverLocation;
326 char *szDriverFile;
327 char *szDontdescend;
328 char *szHostsallow;
329 char *szHostsdeny;
330 char *szMagicScript;
331 char *szMagicOutput;
332 char *szMangledMap;
333 char *szVetoFiles;
334 char *szHideFiles;
335 char *szVetoOplockFiles;
336 char *comment;
337 char *force_user;
338 char *force_group;
339 char *readlist;
340 char *writelist;
341 char *printer_admin;
342 char *volume;
343 char *fstype;
344 char *szVfsObjectFile;
345 char *szVfsOptions;
346 int iMinPrintSpace;
347 int iMaxPrintJobs;
348 int iWriteCacheSize;
349 int iCreate_mask;
350 int iCreate_force_mode;
351 int iSecurity_mask;
352 int iSecurity_force_mode;
353 int iDir_mask;
354 int iDir_force_mode;
355 int iDir_Security_mask;
356 int iDir_Security_force_mode;
357 int iMaxConnections;
358 int iDefaultCase;
359 int iPrinting;
360 int iOplockContentionLimit;
361 int iCSCPolicy;
362 int iBlock_size;
363 BOOL bAlternatePerm;
364 BOOL bPreexecClose;
365 BOOL bRootpreexecClose;
366 BOOL bCaseSensitive;
367 BOOL bCasePreserve;
368 BOOL bShortCasePreserve;
369 BOOL bCaseMangle;
370 BOOL status;
371 BOOL bHideDotFiles;
372 BOOL bHideUnReadable;
373 BOOL bBrowseable;
374 BOOL bAvailable;
375 BOOL bRead_only;
376 BOOL bNo_set_dir;
377 BOOL bGuest_only;
378 BOOL bGuest_ok;
379 BOOL bPrint_ok;
380 BOOL bPostscript;
381 BOOL bMap_system;
382 BOOL bMap_hidden;
383 BOOL bMap_archive;
384 BOOL bLocking;
385 BOOL bStrictLocking;
386 BOOL bPosixLocking;
387 BOOL bShareModes;
388 BOOL bOpLocks;
389 BOOL bLevel2OpLocks;
390 BOOL bOnlyUser;
391 BOOL bMangledNames;
392 BOOL bWidelinks;
393 BOOL bSymlinks;
394 BOOL bSyncAlways;
395 BOOL bStrictAllocate;
396 BOOL bStrictSync;
397 char magic_char;
398 BOOL *copymap;
399 BOOL bDeleteReadonly;
400 BOOL bFakeOplocks;
401 BOOL bDeleteVetoFiles;
402 BOOL bDosFilemode;
403 BOOL bDosFiletimes;
404 BOOL bDosFiletimeResolution;
405 BOOL bFakeDirCreateTimes;
406 BOOL bBlockingLocks;
407 BOOL bInheritPerms;
408 BOOL bInheritACLS;
409 BOOL bMSDfsRoot;
410 BOOL bUseClientDriver;
411 BOOL bDefaultDevmode;
412 BOOL bNTAclSupport;
413 BOOL bForceUnknownAclUser;
414 #ifdef WITH_SENDFILE
415 BOOL bUseSendfile;
416 #endif
417 BOOL bProfileAcls;
419 char dummy[3]; /* for alignment */
421 service;
424 /* This is a default service used to prime a services structure */
425 static service sDefault = {
426 True, /* valid */
427 False, /* not autoloaded */
428 NULL, /* szService */
429 NULL, /* szPath */
430 NULL, /* szUsername */
431 NULL, /* szGuestAccount - this is set in init_globals() */
432 NULL, /* szInvalidUsers */
433 NULL, /* szValidUsers */
434 NULL, /* szAdminUsers */
435 NULL, /* szCopy */
436 NULL, /* szInclude */
437 NULL, /* szPreExec */
438 NULL, /* szPostExec */
439 NULL, /* szRootPreExec */
440 NULL, /* szRootPostExec */
441 NULL, /* szPrintcommand */
442 NULL, /* szLpqcommand */
443 NULL, /* szLprmcommand */
444 NULL, /* szLppausecommand */
445 NULL, /* szLpresumecommand */
446 NULL, /* szQueuepausecommand */
447 NULL, /* szQueueresumecommand */
448 NULL, /* szPrintername */
449 NULL, /* szPrinterDriver - this is set in init_globals() */
450 NULL, /* szPrinterDriverLocation */
451 NULL, /* szDriverFile */
452 NULL, /* szDontdescend */
453 NULL, /* szHostsallow */
454 NULL, /* szHostsdeny */
455 NULL, /* szMagicScript */
456 NULL, /* szMagicOutput */
457 NULL, /* szMangledMap */
458 NULL, /* szVetoFiles */
459 NULL, /* szHideFiles */
460 NULL, /* szVetoOplockFiles */
461 NULL, /* comment */
462 NULL, /* force user */
463 NULL, /* force group */
464 NULL, /* readlist */
465 NULL, /* writelist */
466 NULL, /* printer admin */
467 NULL, /* volume */
468 NULL, /* fstype */
469 NULL, /* vfs object */
470 NULL, /* vfs options */
471 0, /* iMinPrintSpace */
472 1000, /* iMaxPrintJobs */
473 0, /* iWriteCacheSize */
474 0744, /* iCreate_mask */
475 0000, /* iCreate_force_mode */
476 0777, /* iSecurity_mask */
477 0, /* iSecurity_force_mode */
478 0755, /* iDir_mask */
479 0000, /* iDir_force_mode */
480 0777, /* iDir_Security_mask */
481 0, /* iDir_Security_force_mode */
482 0, /* iMaxConnections */
483 CASE_LOWER, /* iDefaultCase */
484 DEFAULT_PRINTING, /* iPrinting */
485 2, /* iOplockContentionLimit */
486 0, /* iCSCPolicy */
487 1024, /* iBlock_size */
488 False, /* bAlternatePerm */
489 False, /* bPreexecClose */
490 False, /* bRootpreexecClose */
491 False, /* case sensitive */
492 True, /* case preserve */
493 True, /* short case preserve */
494 False, /* case mangle */
495 True, /* status */
496 True, /* bHideDotFiles */
497 False, /* bHideUnReadable */
498 True, /* bBrowseable */
499 True, /* bAvailable */
500 True, /* bRead_only */
501 True, /* bNo_set_dir */
502 False, /* bGuest_only */
503 False, /* bGuest_ok */
504 False, /* bPrint_ok */
505 False, /* bPostscript */
506 False, /* bMap_system */
507 False, /* bMap_hidden */
508 True, /* bMap_archive */
509 True, /* bLocking */
510 False, /* bStrictLocking */
511 True, /* bPosixLocking */
512 True, /* bShareModes */
513 True, /* bOpLocks */
514 True, /* bLevel2OpLocks */
515 False, /* bOnlyUser */
516 True, /* bMangledNames */
517 True, /* bWidelinks */
518 True, /* bSymlinks */
519 False, /* bSyncAlways */
520 False, /* bStrictAllocate */
521 False, /* bStrictSync */
522 '~', /* magic char */
523 NULL, /* copymap */
524 False, /* bDeleteReadonly */
525 False, /* bFakeOplocks */
526 False, /* bDeleteVetoFiles */
527 False, /* bDosFilemode */
528 False, /* bDosFiletimes */
529 False, /* bDosFiletimeResolution */
530 False, /* bFakeDirCreateTimes */
531 True, /* bBlockingLocks */
532 False, /* bInheritPerms */
533 False, /* bInheritACLS */
534 False, /* bMSDfsRoot */
535 False, /* bUseClientDriver */
536 False, /* bDefaultDevmode */
537 True, /* bNTAclSupport */
538 False, /* bForceUnknownAclUser */
539 #ifdef WITH_SENDFILE
540 False, /* bUseSendfile */
541 #endif
542 False, /* bProfileAcls */
544 "" /* dummy */
547 /* local variables */
548 static service **ServicePtrs = NULL;
549 static int iNumServices = 0;
550 static int iServiceIndex = 0;
551 static BOOL bInGlobalSection = True;
552 static BOOL bGlobalOnly = False;
553 static int server_role;
554 static int default_server_announce;
556 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
558 /* prototypes for the special type handlers */
559 static BOOL handle_valid_chars(char *pszParmValue, char **ptr);
560 static BOOL handle_include(char *pszParmValue, char **ptr);
561 static BOOL handle_copy(char *pszParmValue, char **ptr);
562 static BOOL handle_character_set(char *pszParmValue, char **ptr);
563 static BOOL handle_coding_system(char *pszParmValue, char **ptr);
564 static BOOL handle_client_code_page(char *pszParmValue, char **ptr);
565 static BOOL handle_vfs_object(char *pszParmValue, char **ptr);
566 static BOOL handle_source_env(char *pszParmValue, char **ptr);
567 static BOOL handle_netbios_name(char *pszParmValue, char **ptr);
568 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
569 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr);
570 static BOOL handle_wins_server_list(char *pszParmValue, char **ptr);
571 static BOOL handle_debug_list( char *pszParmValue, char **ptr );
573 static void set_server_role(void);
574 static void set_default_server_announce_type(void);
576 static struct enum_list enum_protocol[] = {
577 {PROTOCOL_NT1, "NT1"},
578 {PROTOCOL_LANMAN2, "LANMAN2"},
579 {PROTOCOL_LANMAN1, "LANMAN1"},
580 {PROTOCOL_CORE, "CORE"},
581 {PROTOCOL_COREPLUS, "COREPLUS"},
582 {PROTOCOL_COREPLUS, "CORE+"},
583 {-1, NULL}
586 static struct enum_list enum_security[] = {
587 {SEC_SHARE, "SHARE"},
588 {SEC_USER, "USER"},
589 {SEC_SERVER, "SERVER"},
590 {SEC_DOMAIN, "DOMAIN"},
591 {-1, NULL}
594 static struct enum_list enum_printing[] = {
595 {PRINT_SYSV, "sysv"},
596 {PRINT_AIX, "aix"},
597 {PRINT_HPUX, "hpux"},
598 {PRINT_BSD, "bsd"},
599 {PRINT_QNX, "qnx"},
600 {PRINT_PLP, "plp"},
601 {PRINT_LPRNG, "lprng"},
602 {PRINT_SOFTQ, "softq"},
603 {PRINT_CUPS, "cups"},
604 {PRINT_LPRNT, "nt"},
605 {PRINT_LPROS2, "os2"},
606 #ifdef DEVELOPER
607 {PRINT_TEST, "test"},
608 {PRINT_VLP, "vlp"},
609 #endif /* DEVELOPER */
610 {-1, NULL}
613 #ifdef WITH_LDAP_SAM
614 static struct enum_list enum_ldap_ssl[] = {
615 {LDAP_SSL_ON, "Yes"},
616 {LDAP_SSL_ON, "yes"},
617 {LDAP_SSL_ON, "on"},
618 {LDAP_SSL_ON, "On"},
619 {LDAP_SSL_OFF, "no"},
620 {LDAP_SSL_OFF, "No"},
621 {LDAP_SSL_OFF, "off"},
622 {LDAP_SSL_OFF, "Off"},
623 {LDAP_SSL_START_TLS, "start tls"},
624 {LDAP_SSL_START_TLS, "start_tls"},
625 {-1, NULL}
627 #endif
629 /* Types of machine we can announce as. */
630 #define ANNOUNCE_AS_NT_SERVER 1
631 #define ANNOUNCE_AS_WIN95 2
632 #define ANNOUNCE_AS_WFW 3
633 #define ANNOUNCE_AS_NT_WORKSTATION 4
635 static struct enum_list enum_announce_as[] = {
636 {ANNOUNCE_AS_NT_SERVER, "NT"},
637 {ANNOUNCE_AS_NT_SERVER, "NT Server"},
638 {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
639 {ANNOUNCE_AS_WIN95, "win95"},
640 {ANNOUNCE_AS_WFW, "WfW"},
641 {-1, NULL}
644 static struct enum_list enum_case[] = {
645 {CASE_LOWER, "lower"},
646 {CASE_UPPER, "upper"},
647 {-1, NULL}
650 static struct enum_list enum_bool_auto[] = {
651 {False, "No"},
652 {False, "False"},
653 {False, "0"},
654 {True, "Yes"},
655 {True, "True"},
656 {True, "1"},
657 {Auto, "Auto"},
658 {-1, NULL}
661 /* Client-side offline caching policy types */
662 #define CSC_POLICY_MANUAL 0
663 #define CSC_POLICY_DOCUMENTS 1
664 #define CSC_POLICY_PROGRAMS 2
665 #define CSC_POLICY_DISABLE 3
667 static struct enum_list enum_csc_policy[] = {
668 {CSC_POLICY_MANUAL, "manual"},
669 {CSC_POLICY_DOCUMENTS, "documents"},
670 {CSC_POLICY_PROGRAMS, "programs"},
671 {CSC_POLICY_DISABLE, "disable"},
672 {-1,NULL}
676 Do you want session setups at user level security with a invalid
677 password to be rejected or allowed in as guest? WinNT rejects them
678 but it can be a pain as it means "net view" needs to use a password
680 You have 3 choices in the setting of map_to_guest:
682 "Never" means session setups with an invalid password
683 are rejected. This is the default.
685 "Bad User" means session setups with an invalid password
686 are rejected, unless the username does not exist, in which case it
687 is treated as a guest login
689 "Bad Password" means session setups with an invalid password
690 are treated as a guest login
692 Note that map_to_guest only has an effect in user or server
693 level security.
696 static struct enum_list enum_map_to_guest[] = {
697 {NEVER_MAP_TO_GUEST, "Never"},
698 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
699 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
700 {-1, NULL}
703 #ifdef WITH_SSL
704 static struct enum_list enum_ssl_version[] = {
705 {SMB_SSL_V2, "ssl2"},
706 {SMB_SSL_V3, "ssl3"},
707 {SMB_SSL_V23, "ssl2or3"},
708 {SMB_SSL_TLS1, "tls1"},
709 {-1, NULL}
711 #endif
713 /* note that we do not initialise the defaults union - it is not allowed in ANSI C */
714 static struct parm_struct parm_table[] = {
715 {"Base Options", P_SEP, P_SEPARATOR},
717 {"coding system", P_STRING, P_GLOBAL, &Globals.szCodingSystem, handle_coding_system, NULL, 0},
718 {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, handle_client_code_page, NULL, 0},
719 {"code page directory", P_STRING, P_GLOBAL, &Globals.szCodePageDir, NULL, NULL, 0},
720 {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT | FLAG_DOS_STRING},
721 {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT | FLAG_DOS_STRING},
722 {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_DOS_STRING},
723 {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC | FLAG_DOS_STRING | FLAG_WIZARD},
724 {"netbios name", P_UGSTRING, P_GLOBAL, global_myname, handle_netbios_name, NULL, FLAG_BASIC | FLAG_DOS_STRING | FLAG_WIZARD},
725 {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, FLAG_DOS_STRING},
726 {"netbios scope", P_UGSTRING, P_GLOBAL, global_scope, NULL, NULL, FLAG_DOS_STRING},
727 {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_DOS_STRING},
728 {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_WIZARD},
729 {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_WIZARD},
731 {"Security Options", P_SEP, P_SEPARATOR},
733 {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_WIZARD},
734 {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC | FLAG_WIZARD},
735 {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_BASIC},
736 {"allow trusted domains", P_BOOL, P_GLOBAL, &Globals.bAllowTrustedDomains, NULL, NULL, 0},
737 {"alternate permissions", P_BOOL, P_LOCAL, &sDefault.bAlternatePerm, NULL, NULL, FLAG_GLOBAL | FLAG_DEPRECATED},
738 {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, 0},
739 {"min passwd length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, 0},
740 {"min password length", P_INTEGER, P_GLOBAL, &Globals.min_passwd_length, NULL, NULL, 0},
741 {"map to guest", P_ENUM, P_GLOBAL, &Globals.map_to_guest, NULL, enum_map_to_guest, 0},
742 {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, 0},
743 {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, 0},
744 {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, FLAG_WIZARD},
745 #ifdef WITH_TDB_SAM
746 {"tdb passwd file", P_STRING, P_GLOBAL, &Globals.szTDBPasswdFile, NULL, NULL, 0},
747 #else
748 {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, 0},
749 #endif
750 {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
751 {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
752 {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
754 {"pam password change", P_BOOL, P_GLOBAL, &Globals.bPamPasswordChange, NULL, NULL, 0},
755 {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, 0},
756 {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, 0},
757 {"passwd chat debug", P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, 0},
758 {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, 0},
759 {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, 0},
760 {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, 0},
761 {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, 0},
762 {"restrict anonymous", P_BOOL, P_GLOBAL, &Globals.bRestrictAnonymous, NULL, NULL, 0},
763 {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, 0},
764 {"use rhosts", P_BOOL, P_GLOBAL, &Globals.bUseRhosts, NULL, NULL, 0},
766 {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
767 {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
768 {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
770 {"guest account", P_STRING, P_LOCAL, &sDefault.szGuestaccount, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT | FLAG_GLOBAL},
771 {"invalid users", P_STRING, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
772 {"valid users", P_STRING, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
773 {"admin users", P_STRING, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
774 {"read list", P_STRING, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
775 {"write list", P_STRING, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
776 {"printer admin", P_STRING, P_LOCAL, &sDefault.printer_admin, NULL, NULL, FLAG_GLOBAL | FLAG_PRINT},
777 {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, FLAG_SHARE},
778 {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, FLAG_SHARE},
779 {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, 0},
781 {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_SHARE},
782 {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
783 {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
784 {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
786 {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
787 {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL},
788 {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
789 {"security mask", P_OCTAL, P_LOCAL, &sDefault.iSecurity_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
790 {"force security mode", P_OCTAL, P_LOCAL, &sDefault.iSecurity_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
791 {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
792 {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL},
793 {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
794 {"directory security mask", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_mask, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
795 {"force directory security mode", P_OCTAL, P_LOCAL, &sDefault.iDir_Security_force_mode, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
796 {"force unknown acl user", P_OCTAL, P_LOCAL, &sDefault.bForceUnknownAclUser, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE},
797 {"inherit permissions", P_BOOL, P_LOCAL, &sDefault.bInheritPerms, NULL, NULL, FLAG_SHARE},
798 {"inherit acls", P_BOOL, P_LOCAL, &sDefault.bInheritACLS, NULL, NULL, FLAG_SHARE},
799 {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_SHARE},
800 {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, 0},
802 {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
803 {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, 0},
805 {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, FLAG_SHARE},
806 {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
807 {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, 0},
808 {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
809 {"deny hosts", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, 0},
811 #ifdef WITH_SSL
812 {"Secure Socket Layer Options", P_SEP, P_SEPARATOR},
813 {"ssl", P_BOOL, P_GLOBAL, &Globals.sslEnabled, NULL, NULL, 0},
815 {"ssl hosts", P_STRING, P_GLOBAL, &Globals.sslHostsRequire, NULL, NULL, 0},
816 {"ssl hosts resign", P_STRING, P_GLOBAL, &Globals.sslHostsResign, NULL, NULL, 0},
817 {"ssl CA certDir", P_STRING, P_GLOBAL, &Globals.sslCaCertDir, NULL, NULL, 0},
818 {"ssl CA certFile", P_STRING, P_GLOBAL, &Globals.sslCaCertFile, NULL, NULL, 0},
819 {"ssl server cert", P_STRING, P_GLOBAL, &Globals.sslServerCert, NULL, NULL, 0},
820 {"ssl server key", P_STRING, P_GLOBAL, &Globals.sslServerPrivKey, NULL, NULL, 0},
821 {"ssl client cert", P_STRING, P_GLOBAL, &Globals.sslClientCert, NULL, NULL, 0},
822 {"ssl client key", P_STRING, P_GLOBAL, &Globals.sslClientPrivKey, NULL, NULL, 0},
823 {"ssl egd socket", P_STRING, P_GLOBAL, &Globals.sslEgdSocket, NULL, NULL, 0},
824 {"ssl entropy file", P_STRING, P_GLOBAL, &Globals.sslEntropyFile, NULL, NULL, 0},
825 {"ssl entropy bytes", P_INTEGER, P_GLOBAL, &Globals.sslEntropyBytes, NULL, NULL, 0},
826 {"ssl require clientcert", P_BOOL, P_GLOBAL, &Globals.sslReqClientCert, NULL, NULL, 0},
827 {"ssl require servercert", P_BOOL, P_GLOBAL, &Globals.sslReqServerCert, NULL, NULL, 0},
828 {"ssl ciphers", P_STRING, P_GLOBAL, &Globals.sslCiphers, NULL, NULL, 0},
829 {"ssl version", P_ENUM, P_GLOBAL, &Globals.sslVersion, NULL, enum_ssl_version, 0},
830 {"ssl compatibility", P_BOOL, P_GLOBAL, &Globals.sslCompatibility, NULL, NULL, 0},
831 #endif /* WITH_SSL */
833 {"Logging Options", P_SEP, P_SEPARATOR},
835 {"admin log", P_BOOL, P_GLOBAL, &Globals.bAdminLog, NULL, NULL, 0},
836 {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
837 {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
838 {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, 0},
839 {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, 0},
840 {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, 0},
842 {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, 0},
843 {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, 0},
844 {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, 0},
845 {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, 0},
846 {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, 0},
847 {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, 0},
849 {"status", P_BOOL, P_LOCAL, &sDefault.status, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE | FLAG_PRINT | FLAG_DEPRECATED},
851 {"Protocol Options", P_SEP, P_SEPARATOR},
853 {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, 0},
854 {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, 0},
855 {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, 0},
856 {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, 0},
857 {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, 0},
858 {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, 0},
859 {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, 0},
861 {"nt smb support", P_BOOL, P_GLOBAL, &Globals.bNTSmbSupport, NULL, NULL, 0},
862 {"nt pipe support", P_BOOL, P_GLOBAL, &Globals.bNTPipeSupport, NULL, NULL, 0},
863 {"nt acl support", P_BOOL, P_LOCAL, &sDefault.bNTAclSupport, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE },
864 {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, 0 },
865 {"profile acls", P_BOOL, P_LOCAL, &sDefault.bProfileAcls, NULL, NULL, FLAG_GLOBAL | FLAG_SHARE },
866 {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, 0},
867 {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
868 {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
869 {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, 0},
871 {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, 0},
872 {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, 0},
873 {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, 0},
874 {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, 0},
875 {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, 0},
876 {"unix extensions", P_BOOL, P_GLOBAL, &Globals.bUnixExtensions, NULL, NULL, 0},
878 {"Tuning Options", P_SEP, P_SEPARATOR},
880 {"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
881 {"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, 0},
882 {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, 0},
883 {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, 0},
884 {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, 0},
886 {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, 0},
887 {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, 0},
888 {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_SHARE},
889 {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, 0},
890 {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, 0},
891 {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_PRINT},
892 {"name cache timeout", P_INTEGER, P_GLOBAL, &Globals.name_cache_timeout, NULL, NULL, 0},
893 {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL, 0},
895 {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, 0},
896 {"stat cache size", P_INTEGER, P_GLOBAL, &Globals.stat_cache_size, NULL, NULL, 0},
897 {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_SHARE},
898 {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_SHARE},
899 {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_SHARE},
900 {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, 0},
901 #ifdef WITH_SENDFILE
902 {"use sendfile", P_BOOL, P_LOCAL, &sDefault.bUseSendfile, NULL, NULL, FLAG_SHARE},
903 #endif
904 {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_SHARE},
906 {"Printing Options", P_SEP, P_SEPARATOR},
908 {"total print jobs", P_INTEGER, P_GLOBAL, &Globals.iTotalPrintJobs, NULL, NULL, FLAG_PRINT},
909 {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_PRINT},
910 {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_PRINT},
911 {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_PRINT},
912 {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, 0},
913 {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_PRINT},
914 {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, 0},
915 {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
916 {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, NULL, enum_printing, FLAG_PRINT | FLAG_GLOBAL},
917 {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
918 {"disable spoolss", P_BOOL, P_GLOBAL, &Globals.bDisableSpoolss, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
919 {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
920 {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
921 {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
922 {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
923 {"queuepause command", P_STRING, P_LOCAL, &sDefault.szQueuepausecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
924 {"queueresume command", P_STRING, P_LOCAL, &sDefault.szQueueresumecommand, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
926 {"enumports command", P_STRING, P_GLOBAL, &Globals.szEnumPortsCommand, NULL, NULL, 0},
927 {"addprinter command", P_STRING, P_GLOBAL, &Globals.szAddPrinterCommand, NULL, NULL, 0},
928 {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, 0},
929 {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, 0},
930 {"os2 driver map", P_STRING, P_GLOBAL, &Globals.szOs2DriverMap, NULL, NULL, 0},
932 {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT|FLAG_DOS_STRING},
933 {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_DOS_STRING},
934 {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_PRINT},
935 {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_PRINT},
936 {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
937 {"printer driver file", P_STRING, P_LOCAL, &sDefault.szDriverFile, NULL, NULL, FLAG_PRINT | FLAG_DEPRECATED},
938 {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL | FLAG_DEPRECATED},
940 {"Filename Handling", P_SEP, P_SEPARATOR},
941 {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL, FLAG_DEPRECATED },
942 {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, 0},
944 {"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set, NULL, 0},
945 {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL, 0},
946 {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, FLAG_SHARE},
947 {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
948 {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, 0},
949 {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
950 {"short preserve case", P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
951 {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
952 {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
953 {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
954 {"hide unreadable", P_BOOL, P_LOCAL, &sDefault.bHideUnReadable, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
955 {"delete veto files", P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
956 {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL | FLAG_DOS_STRING},
957 {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL | FLAG_DOS_STRING},
958 {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL | FLAG_DOS_STRING},
959 {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
960 {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
961 {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
962 {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
963 {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
964 {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, 0},
966 {"Domain Options", P_SEP, P_SEPARATOR},
968 {"domain admin group", P_STRING, P_GLOBAL, &Globals.szDomainAdminGroup, NULL, NULL, 0},
969 {"domain guest group", P_STRING, P_GLOBAL, &Globals.szDomainGuestGroup, NULL, NULL, 0},
970 #ifdef USING_GROUPNAME_MAP
972 {"groupname map", P_STRING, P_GLOBAL, &Globals.szGroupnameMap, NULL, NULL, 0},
973 #endif /* USING_GROUPNAME_MAP */
975 {"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, 0},
977 {"Logon Options", P_SEP, P_SEPARATOR},
979 {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, 0},
980 {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, 0},
981 {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, FLAG_DOS_STRING},
982 {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, FLAG_DOS_STRING},
983 {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, 0},
984 {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, FLAG_DOS_STRING},
985 {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, 0},
987 {"Browse Options", P_SEP, P_SEPARATOR},
989 {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC},
990 {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, 0},
991 {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, 0},
992 {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC},
993 {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
994 {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC},
995 {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC},
996 {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, 0},
997 {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
998 {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, 0},
999 {"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL},
1001 {"WINS Options", P_SEP, P_SEPARATOR},
1002 {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, 0},
1003 {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, 0},
1005 {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, handle_wins_server_list, NULL, FLAG_BASIC | FLAG_WIZARD},
1006 {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC | FLAG_WIZARD},
1007 {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, 0},
1009 {"Locking Options", P_SEP, P_SEPARATOR},
1011 {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1012 {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_SHARE | FLAG_GLOBAL},
1013 {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_SHARE},
1014 {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_GLOBAL},
1015 {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1016 {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_GLOBAL},
1017 {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_GLOBAL},
1019 {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1020 {"level2 oplocks", P_BOOL, P_LOCAL, &sDefault.bLevel2OpLocks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1021 {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_GLOBAL},
1022 {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1023 {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1024 {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1025 {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL},
1027 #ifdef WITH_LDAP_SAM
1028 {"Ldap Options", P_SEP, P_SEPARATOR},
1030 {"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, 0},
1031 {"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, 0},
1032 {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, NULL, NULL, 0},
1033 {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, 0},
1034 {"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, 0},
1035 {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, 0},
1036 #endif /* WITH_LDAP_SAM */
1038 {"Miscellaneous Options", P_SEP, P_SEPARATOR},
1039 {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, 0},
1040 {"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, 0},
1041 {"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, 0},
1043 {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
1044 {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_DOS_STRING},
1045 {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_DOS_STRING},
1046 {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
1047 {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
1048 {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, 0},
1049 #ifdef WITH_UTMP
1050 {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, 0},
1051 {"wtmp directory", P_STRING, P_GLOBAL, &Globals.szWtmpDir, NULL, NULL, 0},
1052 {"utmp", P_BOOL, P_GLOBAL, &Globals.bUtmp, NULL, NULL, 0},
1053 #endif
1055 {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_DOS_STRING},
1056 {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, FLAG_DOS_STRING},
1057 {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, 0},
1058 {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, 0},
1059 {"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars, NULL, 0},
1060 {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, 0},
1061 {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL, NULL, 0},
1062 {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, 0},
1063 {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, 0},
1064 {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, 0},
1065 {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, 0},
1066 {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
1068 {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
1069 {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
1070 {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1071 {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, 0},
1073 {"preexec close", P_BOOL, P_LOCAL, &sDefault.bPreexecClose, NULL, NULL, FLAG_SHARE},
1074 {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1075 {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1076 {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_SHARE},
1077 {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_SHARE | FLAG_PRINT},
1078 {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
1079 {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_SHARE | FLAG_DOS_STRING},
1080 {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_SHARE},
1081 {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_SHARE},
1082 {"source environment", P_STRING, P_GLOBAL, &Globals.szSourceEnv, handle_source_env, NULL, 0},
1083 {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1084 {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1085 {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_SHARE},
1086 {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_SHARE},
1087 {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_SHARE},
1088 {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1089 {"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1090 {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1091 {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1093 {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
1094 {"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL, 0},
1095 {"hide local users", P_BOOL, P_GLOBAL, &Globals.bHideLocalUsers, NULL,
1096 NULL, 0},
1098 {"VFS module options", P_SEP, P_SEPARATOR},
1100 {"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, FLAG_SHARE},
1101 {"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, FLAG_SHARE},
1103 #ifdef WITH_MSDFS
1104 {"MSDfs options", P_SEP, P_SEPARATOR},
1106 {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE},
1107 {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, 0},
1108 #endif
1110 {"Winbind options", P_SEP, P_SEPARATOR},
1112 {"winbind uid", P_STRING, P_GLOBAL, &Globals.szWinbindUID, handle_winbind_uid, NULL, 0},
1113 {"winbind gid", P_STRING, P_GLOBAL, &Globals.szWinbindGID, handle_winbind_gid, NULL, 0},
1114 {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, 0},
1115 {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, 0},
1116 {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, 0},
1117 {"winbind cache time", P_INTEGER, P_GLOBAL, &Globals.winbind_cache_time, NULL, NULL, 0},
1118 {"winbind enum users", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumUsers, NULL, NULL, 0},
1119 {"winbind enum groups", P_BOOL, P_GLOBAL, &Globals.bWinbindEnumGroups, NULL, NULL, 0},
1120 {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, 0},
1122 {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
1126 /***************************************************************************
1127 Initialise the sDefault parameter structure for the printer values.
1128 ***************************************************************************/
1129 static void init_printer_values(void)
1131 string_set(&sDefault.szPrinterDriver, "");
1132 string_set(&sDefault.szDriverFile, DRIVERFILE);
1134 /* choose defaults depending on the type of printing */
1135 switch (sDefault.iPrinting)
1137 case PRINT_BSD:
1138 case PRINT_AIX:
1139 case PRINT_LPRNT:
1140 case PRINT_LPROS2:
1141 string_set(&sDefault.szLpqcommand, "lpq -P%p");
1142 string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1143 string_set(&sDefault.szPrintcommand,
1144 "lpr -r -P%p %s");
1145 break;
1147 case PRINT_LPRNG:
1148 case PRINT_PLP:
1149 string_set(&sDefault.szLpqcommand, "lpq -P%p");
1150 string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1151 string_set(&sDefault.szPrintcommand,
1152 "lpr -r -P%p %s");
1153 string_set(&sDefault.szQueuepausecommand,
1154 "lpc stop %p");
1155 string_set(&sDefault.szQueueresumecommand,
1156 "lpc start %p");
1157 string_set(&sDefault.szLppausecommand,
1158 "lpc hold %p %j");
1159 string_set(&sDefault.szLpresumecommand,
1160 "lpc release %p %j");
1161 break;
1163 case PRINT_CUPS:
1164 #ifdef HAVE_CUPS
1165 string_set(&sDefault.szLpqcommand, "");
1166 string_set(&sDefault.szLprmcommand, "");
1167 string_set(&sDefault.szPrintcommand, "");
1168 string_set(&sDefault.szLppausecommand, "");
1169 string_set(&sDefault.szLpresumecommand, "");
1170 string_set(&sDefault.szQueuepausecommand, "");
1171 string_set(&sDefault.szQueueresumecommand, "");
1173 string_set(&Globals.szPrintcapname, "cups");
1174 #else
1175 string_set(&sDefault.szLpqcommand,
1176 "/usr/bin/lpstat -o %p");
1177 string_set(&sDefault.szLprmcommand,
1178 "/usr/bin/cancel %p-%j");
1179 string_set(&sDefault.szPrintcommand,
1180 "/usr/bin/lp -d %p %s; rm %s");
1181 string_set(&sDefault.szLppausecommand,
1182 "lp -i %p-%j -H hold");
1183 string_set(&sDefault.szLpresumecommand,
1184 "lp -i %p-%j -H resume");
1185 string_set(&sDefault.szQueuepausecommand,
1186 "/usr/bin/disable %p");
1187 string_set(&sDefault.szQueueresumecommand,
1188 "/usr/bin/enable %p");
1189 string_set(&Globals.szPrintcapname, "lpstat");
1190 #endif /* HAVE_CUPS */
1191 break;
1193 case PRINT_SYSV:
1194 case PRINT_HPUX:
1195 string_set(&sDefault.szLpqcommand, "lpstat -o%p");
1196 string_set(&sDefault.szLprmcommand, "cancel %p-%j");
1197 string_set(&sDefault.szPrintcommand,
1198 "lp -c -d%p %s; rm %s");
1199 string_set(&sDefault.szQueuepausecommand,
1200 "disable %p");
1201 string_set(&sDefault.szQueueresumecommand,
1202 "enable %p");
1203 #ifndef HPUX
1204 string_set(&sDefault.szLppausecommand,
1205 "lp -i %p-%j -H hold");
1206 string_set(&sDefault.szLpresumecommand,
1207 "lp -i %p-%j -H resume");
1208 #endif /* SYSV */
1209 break;
1211 case PRINT_QNX:
1212 string_set(&sDefault.szLpqcommand, "lpq -P%p");
1213 string_set(&sDefault.szLprmcommand, "lprm -P%p %j");
1214 string_set(&sDefault.szPrintcommand, "lp -r -P%p %s");
1215 break;
1217 case PRINT_SOFTQ:
1218 string_set(&sDefault.szLpqcommand, "qstat -l -d%p");
1219 string_set(&sDefault.szLprmcommand,
1220 "qstat -s -j%j -c");
1221 string_set(&sDefault.szPrintcommand,
1222 "lp -d%p -s %s; rm %s");
1223 string_set(&sDefault.szLppausecommand,
1224 "qstat -s -j%j -h");
1225 string_set(&sDefault.szLpresumecommand,
1226 "qstat -s -j%j -r");
1227 break;
1228 #ifdef DEVELOPER
1229 case PRINT_TEST:
1230 case PRINT_VLP:
1231 string_set(&sDefault.szPrintcommand, "vlp print %p %s");
1232 string_set(&sDefault.szLpqcommand, "vlp lpq %p");
1233 string_set(&sDefault.szLprmcommand, "vlp lprm %p %j");
1234 string_set(&sDefault.szLppausecommand, "vlp lppause %p %j");
1235 string_set(&sDefault.szLpresumecommand, "vlp lpresum %p %j");
1236 string_set(&sDefault.szQueuepausecommand, "vlp queuepause %p");
1237 string_set(&sDefault.szQueueresumecommand, "vlp queueresume %p");
1238 break;
1239 #endif /* DEVELOPER */
1244 /***************************************************************************
1245 Initialise the global parameter structure.
1246 ***************************************************************************/
1247 static void init_globals(void)
1249 static BOOL done_init = False;
1250 pstring s;
1252 if (!done_init)
1254 int i;
1255 memset((void *)&Globals, '\0', sizeof(Globals));
1257 for (i = 0; parm_table[i].label; i++)
1258 if ((parm_table[i].type == P_STRING ||
1259 parm_table[i].type == P_USTRING) &&
1260 parm_table[i].ptr)
1261 string_set(parm_table[i].ptr, "");
1263 string_set(&sDefault.szGuestaccount, GUEST_ACCOUNT);
1264 string_set(&sDefault.fstype, FSTYPE_STRING);
1266 init_printer_values();
1268 done_init = True;
1272 DEBUG(3, ("Initialising global parameters\n"));
1274 #ifdef WITH_TDB_SAM
1275 string_set(&Globals.szTDBPasswdFile, TDB_PASSWD_FILE);
1276 #else
1277 string_set(&Globals.szSMBPasswdFile, SMB_PASSWD_FILE);
1278 #endif
1280 /* use the old 'hash' method by default */
1281 string_set(&Globals.szManglingMethod, "hash");
1284 * Allow the default PASSWD_CHAT to be overridden in local.h.
1286 string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
1287 string_set(&Globals.szWorkGroup, WORKGROUP);
1288 string_set(&Globals.szPasswdProgram, PASSWD_PROGRAM);
1289 string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
1290 string_set(&Globals.szLockDir, LOCKDIR);
1291 string_set(&Globals.szPidDir, PIDDIR);
1292 #ifdef WITH_UTMP
1293 string_set(&Globals.szUtmpDir, "");
1294 string_set(&Globals.szWtmpDir, "");
1295 Globals.bUtmp = False;
1296 #endif
1297 string_set(&Globals.szSocketAddress, "0.0.0.0");
1298 pstrcpy(s, "Samba ");
1299 pstrcat(s, VERSION);
1300 string_set(&Globals.szServerString, s);
1301 slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
1302 DEFAULT_MINOR_VERSION);
1303 string_set(&Globals.szAnnounceVersion, s);
1305 pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
1307 string_set(&Globals.szLogonDrive, "");
1308 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
1309 string_set(&Globals.szLogonHome, "\\\\%N\\%U");
1310 string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
1312 string_set(&Globals.szNameResolveOrder, "lmhosts host wins bcast");
1313 string_set(&Globals.szCodePageDir, CODEPAGEDIR);
1315 Globals.bLoadPrinters = True;
1316 Globals.bUseRhosts = False;
1317 Globals.mangled_stack = 50;
1318 /* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
1319 /* Discovered by 2 days of pain by Don McCall @ HP :-). */
1320 Globals.max_xmit = 0x4104;
1321 Globals.max_mux = 50; /* This is *needed* for profile support. */
1322 Globals.lpqcachetime = 10;
1323 Globals.bDisableSpoolss = False;
1324 Globals.iMaxSmbdProcesses = 0;/* no limit specified */
1325 Globals.iTotalPrintJobs = 0; /* no limit specified */
1326 Globals.pwordlevel = 0;
1327 Globals.unamelevel = 0;
1328 Globals.deadtime = 0;
1329 Globals.bLargeReadwrite = True;
1330 Globals.max_log_size = 5000;
1331 Globals.max_open_files = MAX_OPEN_FILES;
1332 Globals.maxprotocol = PROTOCOL_NT1;
1333 Globals.minprotocol = PROTOCOL_CORE;
1334 Globals.security = SEC_USER;
1335 Globals.bEncryptPasswords = False;
1336 Globals.bUpdateEncrypt = False;
1337 Globals.bReadRaw = True;
1338 Globals.bWriteRaw = True;
1339 Globals.bReadPrediction = False;
1340 Globals.bReadbmpx = False;
1341 Globals.bNullPasswords = False;
1342 Globals.bObeyPamRestrictions = False;
1343 Globals.bStripDot = False;
1344 Globals.syslog = 1;
1345 Globals.bSyslogOnly = False;
1346 Globals.bAdminLog = False;
1347 Globals.bTimestampLogs = True;
1348 Globals.bDebugHiresTimestamp = False;
1349 Globals.bDebugPid = False;
1350 Globals.bDebugUid = False;
1351 Globals.max_ttl = 60 * 60 * 24 * 3; /* 3 days default. */
1352 Globals.max_wins_ttl = 60 * 60 * 24 * 6; /* 6 days default. */
1353 Globals.min_wins_ttl = 60 * 60 * 6; /* 6 hours default. */
1354 Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
1355 Globals.change_notify_timeout = 60; /* 1 minute default. */
1356 Globals.ReadSize = 16 * 1024;
1357 Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
1358 Globals.lm_interval = 60;
1359 Globals.stat_cache_size = 50; /* Number of stat translations we'll keep */
1360 Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
1361 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
1362 Globals.bNISHomeMap = False;
1363 #ifdef WITH_NISPLUS_HOME
1364 string_set(&Globals.szNISHomeMapName, "auto_home.org_dir");
1365 #else
1366 string_set(&Globals.szNISHomeMapName, "auto.home");
1367 #endif
1368 #endif
1369 Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE;
1370 Globals.bTimeServer = False;
1371 Globals.bBindInterfacesOnly = False;
1372 Globals.bUnixPasswdSync = False;
1373 Globals.bPamPasswordChange = False;
1374 Globals.bPasswdChatDebug = False;
1375 Globals.bNTSmbSupport = True; /* Do NT SMB's by default. */
1376 Globals.bNTPipeSupport = True; /* Do NT pipes by default. */
1377 Globals.bStatCache = True; /* use stat cache by default */
1378 Globals.bNTStatusSupport = True; /* Use NT status by default. */
1379 Globals.bRestrictAnonymous = False;
1380 Globals.bLanmanAuth = True; /* Do use the LanMan hash if it is available */
1381 Globals.map_to_guest = 0; /* By Default, "Never" */
1382 Globals.min_passwd_length = MINPASSWDLENGTH; /* By Default, 5. */
1383 Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */
1384 Globals.enhanced_browsing = True;
1385 Globals.iLockSpinCount = 3; /* Try 2 times. */
1386 Globals.iLockSpinTime = 10; /* usec. */
1387 #ifdef MMAP_BLACKLIST
1388 Globals.bUseMmap = False;
1389 #else
1390 Globals.bUseMmap = True;
1391 #endif
1392 Globals.bUnixExtensions = False;
1394 #ifdef WITH_SSL
1395 Globals.sslVersion = SMB_SSL_V23;
1396 string_set(&Globals.sslHostsRequire, "");
1397 string_set(&Globals.sslHostsResign, "");
1398 string_set(&Globals.sslCaCertDir, "");
1399 string_set(&Globals.sslCaCertFile, "");
1400 string_set(&Globals.sslServerCert, "");
1401 string_set(&Globals.sslServerPrivKey, "");
1402 string_set(&Globals.sslClientCert, "");
1403 string_set(&Globals.sslClientPrivKey, "");
1404 string_set(&Globals.sslCiphers, "");
1405 string_set(&Globals.sslEgdSocket, "");
1406 string_set(&Globals.sslEntropyFile, "");
1407 Globals.sslEntropyBytes = 256;
1408 Globals.sslEnabled = False;
1409 Globals.sslReqClientCert = False;
1410 Globals.sslReqServerCert = False;
1411 Globals.sslCompatibility = False;
1412 #endif /* WITH_SSL */
1414 #ifdef WITH_LDAP_SAM
1415 string_set(&Globals.szLdapServer, "localhost");
1416 string_set(&Globals.szLdapSuffix, "");
1417 string_set(&Globals.szLdapFilter, "(&(uid=%u)(objectclass=sambaAccount))");
1418 string_set(&Globals.szLdapAdminDn, "");
1419 Globals.ldap_port = 636;
1420 Globals.ldap_ssl = LDAP_SSL_ON;
1421 #endif /* WITH_LDAP_SAM */
1422 /* these parameters are set to defaults that are more appropriate
1423 for the increasing samba install base:
1425 as a member of the workgroup, that will possibly become a
1426 _local_ master browser (lm = True). this is opposed to a forced
1427 local master browser startup (pm = True).
1429 doesn't provide WINS server service by default (wsupp = False),
1430 and doesn't provide domain master browser services by default, either.
1434 Globals.bMsAddPrinterWizard = True;
1435 Globals.bPreferredMaster = Auto; /* depending on bDomainMaster */
1436 Globals.os_level = 20;
1437 Globals.bLocalMaster = True;
1438 Globals.bDomainMaster = Auto; /* depending on bDomainLogons */
1439 Globals.bDomainLogons = False;
1440 Globals.bBrowseList = True;
1441 Globals.bWINSsupport = False;
1442 Globals.bWINSproxy = False;
1444 Globals.bDNSproxy = True;
1446 /* this just means to use them if they exist */
1447 Globals.bKernelOplocks = True;
1449 Globals.bAllowTrustedDomains = True;
1451 string_set(&Globals.szTemplateShell, "/bin/false");
1452 string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
1453 string_set(&Globals.szWinbindSeparator, "\\");
1454 Globals.winbind_cache_time = 15;
1456 Globals.bWinbindEnumUsers = True;
1457 Globals.bWinbindEnumGroups = True;
1458 Globals.bWinbindUseDefaultDomain = False;
1460 Globals.bHostMSDfs = False;
1462 Globals.name_cache_timeout = 660; /* In seconds */
1465 * This must be done last as it checks the value in
1466 * client_code_page.
1469 interpret_coding_system(KANJI);
1472 static TALLOC_CTX *lp_talloc;
1474 /******************************************************************* a
1475 free up temporary memory - called from the main loop
1476 ********************************************************************/
1477 void lp_talloc_free(void)
1479 if (!lp_talloc)
1480 return;
1481 talloc_destroy(lp_talloc);
1482 lp_talloc = NULL;
1485 /*******************************************************************
1486 convenience routine to grab string parameters into temporary memory
1487 and run standard_sub_basic on them. The buffers can be written to by
1488 callers without affecting the source string.
1489 ********************************************************************/
1490 static char *lp_string(const char *s)
1492 size_t len = s ? strlen(s) : 0;
1493 char *ret;
1495 if (!lp_talloc)
1496 lp_talloc = talloc_init();
1498 ret = (char *)talloc(lp_talloc, len + 100); /* leave room for substitution */
1500 if (!ret)
1501 return NULL;
1503 if (!s)
1504 *ret = 0;
1505 else
1506 StrnCpy(ret, s, len);
1508 trim_string(ret, "\"", "\"");
1510 standard_sub_basic(ret, len + 100);
1511 return (ret);
1516 In this section all the functions that are used to access the
1517 parameters from the rest of the program are defined
1520 #define FN_GLOBAL_STRING(fn_name,ptr) \
1521 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
1522 #define FN_GLOBAL_BOOL(fn_name,ptr) \
1523 BOOL fn_name(void) {return(*(BOOL *)(ptr));}
1524 #define FN_GLOBAL_CHAR(fn_name,ptr) \
1525 char fn_name(void) {return(*(char *)(ptr));}
1526 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
1527 int fn_name(void) {return(*(int *)(ptr));}
1529 #define FN_LOCAL_STRING(fn_name,val) \
1530 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
1531 #define FN_LOCAL_CONST_STRING(fn_name,val) \
1532 const char *fn_name(int i) {return(const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
1533 #define FN_LOCAL_BOOL(fn_name,val) \
1534 BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1535 #define FN_LOCAL_CHAR(fn_name,val) \
1536 char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1537 #define FN_LOCAL_INTEGER(fn_name,val) \
1538 int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
1540 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
1541 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
1542 #ifdef WITH_TDB_SAM
1543 FN_GLOBAL_STRING(lp_tdb_passwd_file, &Globals.szTDBPasswdFile)
1544 #else
1545 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
1546 #endif
1547 FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
1548 FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
1549 FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
1550 FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
1551 FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
1552 FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
1553 FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
1554 FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
1555 #ifdef WITH_UTMP
1556 FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
1557 FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
1558 FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
1559 #endif
1560 FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
1561 FN_GLOBAL_STRING(lp_source_environment, &Globals.szSourceEnv)
1562 FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
1563 FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
1564 FN_GLOBAL_STRING(lp_dfree_command, &Globals.szDfree)
1565 FN_GLOBAL_STRING(lp_hosts_equiv, &Globals.szHostsEquiv)
1566 FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
1567 FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
1568 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
1569 FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
1570 FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
1571 FN_GLOBAL_STRING(lp_workgroup, &Globals.szWorkGroup)
1572 FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
1573 #ifdef USING_GROUPNAME_MAP
1574 FN_GLOBAL_STRING(lp_groupname_map, &Globals.szGroupnameMap)
1575 #endif /* USING_GROUPNAME_MAP */
1576 FN_GLOBAL_STRING(lp_logon_script, &Globals.szLogonScript)
1577 FN_GLOBAL_STRING(lp_logon_path, &Globals.szLogonPath)
1578 FN_GLOBAL_STRING(lp_logon_drive, &Globals.szLogonDrive)
1579 FN_GLOBAL_STRING(lp_logon_home, &Globals.szLogonHome)
1580 FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
1581 FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
1582 FN_GLOBAL_STRING(lp_wins_server, &Globals.szWINSserver)
1583 FN_GLOBAL_STRING(lp_interfaces, &Globals.szInterfaces)
1584 FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
1585 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
1586 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
1587 FN_GLOBAL_STRING(lp_netbios_aliases, &Globals.szNetbiosAliases)
1588 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
1589 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
1590 FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
1591 FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
1592 FN_GLOBAL_STRING(lp_domain_admin_group, &Globals.szDomainAdminGroup)
1593 FN_GLOBAL_STRING(lp_domain_guest_group, &Globals.szDomainGuestGroup)
1594 FN_GLOBAL_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
1595 FN_GLOBAL_STRING(lp_template_shell, &Globals.szTemplateShell)
1596 FN_GLOBAL_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
1597 FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
1598 FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
1599 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
1600 FN_GLOBAL_STRING(lp_codepagedir,&Globals.szCodePageDir)
1601 #ifdef WITH_LDAP_SAM
1602 FN_GLOBAL_STRING(lp_ldap_server, &Globals.szLdapServer)
1603 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
1604 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
1605 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
1606 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
1607 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
1608 #endif /* WITH_LDAP_SAM */
1609 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
1610 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
1611 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
1612 FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
1614 #ifdef WITH_SSL
1615 FN_GLOBAL_INTEGER(lp_ssl_version, &Globals.sslVersion)
1616 FN_GLOBAL_STRING(lp_ssl_hosts, &Globals.sslHostsRequire)
1617 FN_GLOBAL_STRING(lp_ssl_hosts_resign, &Globals.sslHostsResign)
1618 FN_GLOBAL_STRING(lp_ssl_cacertdir, &Globals.sslCaCertDir)
1619 FN_GLOBAL_STRING(lp_ssl_cacertfile, &Globals.sslCaCertFile)
1620 FN_GLOBAL_STRING(lp_ssl_server_cert, &Globals.sslServerCert)
1621 FN_GLOBAL_STRING(lp_ssl_server_privkey, &Globals.sslServerPrivKey)
1622 FN_GLOBAL_STRING(lp_ssl_client_cert, &Globals.sslClientCert)
1623 FN_GLOBAL_STRING(lp_ssl_client_privkey, &Globals.sslClientPrivKey)
1624 FN_GLOBAL_STRING(lp_ssl_ciphers, &Globals.sslCiphers)
1625 FN_GLOBAL_STRING(lp_ssl_egdsocket, &Globals.sslEgdSocket)
1626 FN_GLOBAL_STRING(lp_ssl_entropyfile, &Globals.sslEntropyFile)
1627 FN_GLOBAL_INTEGER(lp_ssl_entropybytes, &Globals.sslEntropyBytes)
1628 FN_GLOBAL_BOOL(lp_ssl_enabled, &Globals.sslEnabled)
1629 FN_GLOBAL_BOOL(lp_ssl_reqClientCert, &Globals.sslReqClientCert)
1630 FN_GLOBAL_BOOL(lp_ssl_reqServerCert, &Globals.sslReqServerCert)
1631 FN_GLOBAL_BOOL(lp_ssl_compatibility, &Globals.sslCompatibility)
1632 #endif /* WITH_SSL */
1634 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
1635 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
1636 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
1637 FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
1638 FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
1639 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
1640 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
1641 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
1642 FN_GLOBAL_BOOL(lp_use_rhosts, &Globals.bUseRhosts)
1643 FN_GLOBAL_BOOL(lp_readprediction, &Globals.bReadPrediction)
1644 FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
1645 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
1646 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
1647 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
1648 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
1649 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
1650 FN_GLOBAL_BOOL(lp_strip_dot, &Globals.bStripDot)
1651 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
1652 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
1653 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
1654 FN_GLOBAL_BOOL(lp_admin_log, &Globals.bAdminLog)
1655 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
1656 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
1657 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
1658 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
1659 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
1660 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
1661 static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
1662 FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
1663 FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
1664 FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
1665 FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
1666 FN_GLOBAL_BOOL(lp_nt_smb_support, &Globals.bNTSmbSupport)
1667 FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
1668 FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
1669 FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
1670 FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
1671 FN_GLOBAL_BOOL(lp_restrict_anonymous, &Globals.bRestrictAnonymous)
1672 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
1673 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
1674 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
1675 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
1676 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
1677 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
1678 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
1679 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
1680 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
1681 FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
1682 FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
1683 FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
1684 FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
1685 FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
1686 FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
1687 FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
1688 FN_GLOBAL_INTEGER(lp_readsize, &Globals.ReadSize)
1689 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
1690 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
1691 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
1692 FN_GLOBAL_INTEGER(lp_security, &Globals.security)
1693 FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
1694 FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
1695 FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
1696 FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss)
1697 FN_GLOBAL_INTEGER(lp_totalprintjobs, &Globals.iTotalPrintJobs)
1698 FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
1699 FN_GLOBAL_INTEGER(lp_client_code_page, &Globals.client_code_page)
1700 static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
1701 FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
1702 FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
1703 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
1704 FN_GLOBAL_INTEGER(lp_change_notify_timeout, &Globals.change_notify_timeout)
1705 FN_GLOBAL_INTEGER(lp_stat_cache_size, &Globals.stat_cache_size)
1706 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
1707 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
1708 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
1709 FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
1710 FN_GLOBAL_INTEGER(lp_lock_sleep_time, &Globals.iLockSpinTime)
1711 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
1712 FN_LOCAL_STRING(lp_preexec, szPreExec)
1713 FN_LOCAL_STRING(lp_postexec, szPostExec)
1714 FN_LOCAL_STRING(lp_rootpreexec, szRootPreExec)
1715 FN_LOCAL_STRING(lp_rootpostexec, szRootPostExec)
1716 FN_LOCAL_STRING(lp_servicename, szService)
1717 FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
1718 FN_LOCAL_STRING(lp_pathname, szPath)
1719 FN_LOCAL_STRING(lp_dontdescend, szDontdescend)
1720 FN_LOCAL_STRING(lp_username, szUsername)
1721 FN_LOCAL_STRING(lp_guestaccount, szGuestaccount)
1722 FN_LOCAL_STRING(lp_invalid_users, szInvalidUsers)
1723 FN_LOCAL_STRING(lp_valid_users, szValidUsers)
1724 FN_LOCAL_STRING(lp_admin_users, szAdminUsers)
1725 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
1726 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
1727 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
1728 FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
1729 FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
1730 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
1731 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
1732 static FN_LOCAL_STRING(_lp_printername, szPrintername)
1733 FN_LOCAL_STRING(lp_driverfile, szDriverFile)
1734 FN_LOCAL_STRING(lp_printerdriver, szPrinterDriver)
1735 FN_LOCAL_STRING(lp_hostsallow, szHostsallow)
1736 FN_LOCAL_STRING(lp_hostsdeny, szHostsdeny)
1737 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
1738 FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
1739 FN_LOCAL_STRING(lp_comment, comment)
1740 FN_LOCAL_STRING(lp_force_user, force_user)
1741 FN_LOCAL_STRING(lp_force_group, force_group)
1742 FN_LOCAL_STRING(lp_readlist, readlist)
1743 FN_LOCAL_STRING(lp_writelist, writelist)
1744 FN_LOCAL_STRING(lp_printer_admin, printer_admin)
1745 FN_LOCAL_STRING(lp_fstype, fstype)
1746 FN_LOCAL_STRING(lp_vfsobj, szVfsObjectFile)
1747 FN_LOCAL_STRING(lp_vfs_options, szVfsOptions)
1748 static FN_LOCAL_STRING(lp_volume, volume)
1749 FN_LOCAL_STRING(lp_mangled_map, szMangledMap)
1750 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
1751 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
1752 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
1753 FN_LOCAL_STRING(lp_driverlocation, szPrinterDriverLocation)
1754 FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
1755 FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
1756 FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
1757 FN_LOCAL_BOOL(lp_rootpreexec_close, bRootpreexecClose)
1758 FN_LOCAL_BOOL(lp_casesensitive, bCaseSensitive)
1759 FN_LOCAL_BOOL(lp_preservecase, bCasePreserve)
1760 FN_LOCAL_BOOL(lp_shortpreservecase, bShortCasePreserve)
1761 FN_LOCAL_BOOL(lp_casemangle, bCaseMangle)
1762 FN_LOCAL_BOOL(lp_status, status)
1763 FN_LOCAL_BOOL(lp_hide_dot_files, bHideDotFiles)
1764 FN_LOCAL_BOOL(lp_hideunreadable, bHideUnReadable)
1765 FN_LOCAL_BOOL(lp_browseable, bBrowseable)
1766 FN_LOCAL_BOOL(lp_readonly, bRead_only)
1767 FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir)
1768 FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok)
1769 FN_LOCAL_BOOL(lp_guest_only, bGuest_only)
1770 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
1771 FN_LOCAL_BOOL(lp_postscript, bPostscript)
1772 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
1773 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
1774 FN_LOCAL_BOOL(lp_locking, bLocking)
1775 FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
1776 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
1777 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
1778 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
1779 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
1780 FN_LOCAL_BOOL(lp_onlyuser, bOnlyUser)
1781 FN_LOCAL_BOOL(lp_manglednames, bMangledNames)
1782 FN_LOCAL_BOOL(lp_widelinks, bWidelinks)
1783 FN_LOCAL_BOOL(lp_symlinks, bSymlinks)
1784 FN_LOCAL_BOOL(lp_syncalways, bSyncAlways)
1785 FN_LOCAL_BOOL(lp_strict_allocate, bStrictAllocate)
1786 FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
1787 FN_LOCAL_BOOL(lp_map_system, bMap_system)
1788 FN_LOCAL_BOOL(lp_delete_readonly, bDeleteReadonly)
1789 FN_LOCAL_BOOL(lp_fake_oplocks, bFakeOplocks)
1790 FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
1791 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
1792 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
1793 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
1794 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
1795 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
1796 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
1797 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
1798 FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
1799 FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
1800 FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
1801 FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
1802 #ifdef WITH_SENDFILE
1803 FN_LOCAL_BOOL(lp_use_sendfile, bUseSendfile)
1804 #endif
1805 FN_LOCAL_BOOL(lp_profile_acls, bProfileAcls)
1806 FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
1807 FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
1808 FN_LOCAL_INTEGER(lp_security_mask, iSecurity_mask)
1809 FN_LOCAL_INTEGER(lp_force_security_mode, iSecurity_force_mode)
1810 FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
1811 FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
1812 FN_LOCAL_INTEGER(lp_dir_security_mask, iDir_Security_mask)
1813 FN_LOCAL_INTEGER(lp_force_dir_security_mode, iDir_Security_force_mode)
1814 FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
1815 FN_LOCAL_INTEGER(lp_defaultcase, iDefaultCase)
1816 FN_LOCAL_INTEGER(lp_minprintspace, iMinPrintSpace)
1817 FN_LOCAL_INTEGER(lp_printing, iPrinting)
1818 FN_LOCAL_INTEGER(lp_oplock_contention_limit, iOplockContentionLimit)
1819 FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
1820 FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
1821 FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
1822 FN_LOCAL_CHAR(lp_magicchar, magic_char)
1823 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
1824 FN_GLOBAL_BOOL(lp_hide_local_users, &Globals.bHideLocalUsers)
1826 /* local prototypes */
1828 static int map_parameter(char *pszParmName);
1829 static BOOL set_boolean(BOOL *pb, char *pszParmValue);
1830 static int getservicebyname(char *pszServiceName,
1831 service * pserviceDest);
1832 static void copy_service(service * pserviceDest,
1833 service * pserviceSource, BOOL *pcopymapDest);
1834 static BOOL service_ok(int iService);
1835 static BOOL do_parameter(char *pszParmName, char *pszParmValue);
1836 static BOOL do_section(char *pszSectionName);
1837 static void init_copymap(service * pservice);
1840 /***************************************************************************
1841 initialise a service to the defaults
1842 ***************************************************************************/
1843 static void init_service(service * pservice)
1845 memset((char *)pservice, '\0', sizeof(service));
1846 copy_service(pservice, &sDefault, NULL);
1850 /***************************************************************************
1851 free the dynamically allocated parts of a service struct
1852 ***************************************************************************/
1853 static void free_service(service * pservice)
1855 int i;
1856 if (!pservice)
1857 return;
1859 if (pservice->szService)
1860 DEBUG(5,
1861 ("free_service: Freeing service %s\n",
1862 pservice->szService));
1864 string_free(&pservice->szService);
1865 SAFE_FREE(pservice->copymap);
1867 for (i = 0; parm_table[i].label; i++)
1868 if ((parm_table[i].type == P_STRING ||
1869 parm_table[i].type == P_USTRING) &&
1870 parm_table[i].class == P_LOCAL)
1871 string_free((char **)
1872 (((char *)pservice) +
1873 PTR_DIFF(parm_table[i].ptr, &sDefault)));
1875 ZERO_STRUCTP(pservice);
1878 /***************************************************************************
1879 add a new service to the services array initialising it with the given
1880 service. name must be in DOS codepage.
1881 ***************************************************************************/
1882 static int add_a_service(service * pservice, char *name)
1884 int i;
1885 service tservice;
1886 int num_to_alloc = iNumServices + 1;
1888 tservice = *pservice;
1890 /* it might already exist */
1892 if (name)
1894 i = getservicebyname(name, NULL);
1895 if (i >= 0)
1896 return (i);
1899 /* find an invalid one */
1900 for (i = 0; i < iNumServices; i++)
1901 if (!ServicePtrs[i]->valid)
1902 break;
1904 /* if not, then create one */
1905 if (i == iNumServices)
1907 service **tsp;
1909 #ifdef __INSURE__
1910 service **oldservices = iNumServices ? malloc(sizeof(service *) * iNumServices) : NULL;
1912 if (iNumServices)
1913 memcpy(oldservices, ServicePtrs, sizeof(service *) * iNumServices);
1914 #endif
1916 tsp = (service **) Realloc(ServicePtrs,
1917 sizeof(service *) *
1918 num_to_alloc);
1920 if (!tsp) {
1921 DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
1922 return (-1);
1923 } else {
1924 ServicePtrs = tsp;
1925 ServicePtrs[iNumServices] =
1926 (service *) malloc(sizeof(service));
1929 #ifdef __INSURE__
1930 if (iNumServices && (memcmp(oldservices, ServicePtrs, sizeof(service *) * iNumServices) != 0)) {
1931 smb_panic("add_a_service: Realloc corrupted ptrs...\n");
1933 safe_free(oldservices);
1934 #endif
1936 if (!ServicePtrs[iNumServices])
1937 return (-1);
1939 iNumServices++;
1941 else
1942 free_service(ServicePtrs[i]);
1944 ServicePtrs[i]->valid = True;
1946 init_service(ServicePtrs[i]);
1947 copy_service(ServicePtrs[i], &tservice, NULL);
1948 if (name)
1950 string_set(&ServicePtrs[i]->szService, name);
1952 return (i);
1955 /***************************************************************************
1956 add a new home service, with the specified home directory, defaults coming
1957 from service ifrom. homename must be in DOS codepage.
1958 ***************************************************************************/
1959 BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir)
1961 int i;
1963 i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
1965 if (i < 0)
1966 return (False);
1968 if (!(*(ServicePtrs[i]->szPath))
1969 || strequal(ServicePtrs[i]->szPath, lp_pathname(-1)))
1970 string_set(&ServicePtrs[i]->szPath, pszHomedir);
1971 if (!(*(ServicePtrs[i]->comment)))
1973 pstring comment;
1974 slprintf(comment, sizeof(comment) - 1,
1975 "Home directory of %s", pszHomename);
1976 string_set(&ServicePtrs[i]->comment, comment);
1978 ServicePtrs[i]->bAvailable = sDefault.bAvailable;
1979 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
1981 DEBUG(3,
1982 ("adding home directory %s at %s\n", pszHomename, pszHomedir));
1984 return (True);
1987 /***************************************************************************
1988 add a new service, based on an old one. pszService must be in DOS codepage.
1989 ***************************************************************************/
1990 int lp_add_service(char *pszService, int iDefaultService)
1992 return (add_a_service(ServicePtrs[iDefaultService], pszService));
1996 /***************************************************************************
1997 add the IPC service
1998 ***************************************************************************/
1999 static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
2001 pstring comment;
2002 int i = add_a_service(&sDefault, ipc_name);
2004 if (i < 0)
2005 return (False);
2007 slprintf(comment, sizeof(comment) - 1,
2008 "IPC Service (%s)", Globals.szServerString);
2010 string_set(&ServicePtrs[i]->szPath, tmpdir());
2011 string_set(&ServicePtrs[i]->szUsername, "");
2012 string_set(&ServicePtrs[i]->comment, comment);
2013 string_set(&ServicePtrs[i]->fstype, "IPC");
2014 ServicePtrs[i]->status = False;
2015 ServicePtrs[i]->iMaxConnections = 0;
2016 ServicePtrs[i]->bAvailable = True;
2017 ServicePtrs[i]->bRead_only = True;
2018 ServicePtrs[i]->bGuest_only = False;
2019 ServicePtrs[i]->bGuest_ok = guest_ok;
2020 ServicePtrs[i]->bPrint_ok = False;
2021 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2023 DEBUG(3, ("adding IPC service %s\n", ipc_name));
2025 return (True);
2029 /***************************************************************************
2030 add a new printer service, with defaults coming from service iFrom.
2031 printername must be in DOS codepage.
2032 ***************************************************************************/
2033 BOOL lp_add_printer(char *pszPrintername, int iDefaultService)
2035 char *comment = "From Printcap";
2036 int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
2038 if (i < 0)
2039 return (False);
2041 /* note that we do NOT default the availability flag to True - */
2042 /* we take it from the default service passed. This allows all */
2043 /* dynamic printers to be disabled by disabling the [printers] */
2044 /* entry (if/when the 'available' keyword is implemented!). */
2046 /* the printer name is set to the service name. */
2047 string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
2048 string_set(&ServicePtrs[i]->comment, comment);
2049 ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
2050 /* Printers cannot be read_only. */
2051 ServicePtrs[i]->bRead_only = False;
2052 /* No oplocks on printer services. */
2053 ServicePtrs[i]->bOpLocks = False;
2054 /* Printer services must be printable. */
2055 ServicePtrs[i]->bPrint_ok = True;
2057 DEBUG(3, ("adding printer service %s\n", pszPrintername));
2059 return (True);
2062 /***************************************************************************
2063 Map a parameter's string representation to something we can use.
2064 Returns False if the parameter string is not recognised, else TRUE.
2065 ***************************************************************************/
2066 static int map_parameter(char *pszParmName)
2068 int iIndex;
2070 if (*pszParmName == '-')
2071 return (-1);
2073 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2074 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2075 return (iIndex);
2077 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2078 return (-1);
2082 /***************************************************************************
2083 Set a boolean variable from the text value stored in the passed string.
2084 Returns True in success, False if the passed string does not correctly
2085 represent a boolean.
2086 ***************************************************************************/
2087 static BOOL set_boolean(BOOL *pb, char *pszParmValue)
2089 BOOL bRetval;
2091 bRetval = True;
2092 if (strwicmp(pszParmValue, "yes") == 0 ||
2093 strwicmp(pszParmValue, "true") == 0 ||
2094 strwicmp(pszParmValue, "1") == 0)
2095 *pb = True;
2096 else
2097 if (strwicmp(pszParmValue, "no") == 0 ||
2098 strwicmp(pszParmValue, "False") == 0 ||
2099 strwicmp(pszParmValue, "0") == 0)
2100 *pb = False;
2101 else
2103 DEBUG(0,
2104 ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
2105 pszParmValue));
2106 bRetval = False;
2108 return (bRetval);
2111 /***************************************************************************
2112 Find a service by name. Otherwise works like get_service.
2113 ***************************************************************************/
2114 static int getservicebyname(char *pszServiceName, service * pserviceDest)
2116 int iService;
2118 for (iService = iNumServices - 1; iService >= 0; iService--)
2119 if (VALID(iService) &&
2120 strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0)
2122 if (pserviceDest != NULL)
2123 copy_service(pserviceDest, ServicePtrs[iService], NULL);
2124 break;
2127 return (iService);
2132 /***************************************************************************
2133 Copy a service structure to another
2135 If pcopymapDest is NULL then copy all fields
2136 ***************************************************************************/
2137 static void copy_service(service * pserviceDest,
2138 service * pserviceSource, BOOL *pcopymapDest)
2140 int i;
2141 BOOL bcopyall = (pcopymapDest == NULL);
2143 for (i = 0; parm_table[i].label; i++)
2144 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
2145 (bcopyall || pcopymapDest[i]))
2147 void *def_ptr = parm_table[i].ptr;
2148 void *src_ptr =
2149 ((char *)pserviceSource) + PTR_DIFF(def_ptr,
2150 &sDefault);
2151 void *dest_ptr =
2152 ((char *)pserviceDest) + PTR_DIFF(def_ptr,
2153 &sDefault);
2155 switch (parm_table[i].type)
2157 case P_BOOL:
2158 case P_BOOLREV:
2159 *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
2160 break;
2162 case P_INTEGER:
2163 case P_ENUM:
2164 case P_OCTAL:
2165 *(int *)dest_ptr = *(int *)src_ptr;
2166 break;
2168 case P_CHAR:
2169 *(char *)dest_ptr = *(char *)src_ptr;
2170 break;
2172 case P_STRING:
2173 string_set(dest_ptr,
2174 *(char **)src_ptr);
2175 break;
2177 case P_USTRING:
2178 string_set(dest_ptr,
2179 *(char **)src_ptr);
2180 strupper(*(char **)dest_ptr);
2181 break;
2182 default:
2183 break;
2187 if (bcopyall)
2189 init_copymap(pserviceDest);
2190 if (pserviceSource->copymap)
2191 memcpy((void *)pserviceDest->copymap,
2192 (void *)pserviceSource->copymap,
2193 sizeof(BOOL) * NUMPARAMETERS);
2197 /***************************************************************************
2198 Check a service for consistency. Return False if the service is in any way
2199 incomplete or faulty, else True.
2200 ***************************************************************************/
2201 static BOOL service_ok(int iService)
2203 BOOL bRetval;
2205 bRetval = True;
2206 if (ServicePtrs[iService]->szService[0] == '\0')
2208 DEBUG(0,
2209 ("The following message indicates an internal error:\n"));
2210 DEBUG(0, ("No service name in service entry.\n"));
2211 bRetval = False;
2214 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2215 /* I can't see why you'd want a non-printable printer service... */
2216 if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
2217 if (!ServicePtrs[iService]->bPrint_ok) {
2218 DEBUG(0,
2219 ("WARNING: [%s] service MUST be printable!\n",
2220 ServicePtrs[iService]->szService));
2221 ServicePtrs[iService]->bPrint_ok = True;
2223 /* [printers] service must also be non-browsable. */
2224 if (ServicePtrs[iService]->bBrowseable)
2225 ServicePtrs[iService]->bBrowseable = False;
2228 if (ServicePtrs[iService]->szPath[0] == '\0' &&
2229 strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0)
2231 DEBUG(0,
2232 ("No path in service %s - using %s\n",
2233 ServicePtrs[iService]->szService, tmpdir()));
2234 string_set(&ServicePtrs[iService]->szPath, tmpdir());
2237 /* If a service is flagged unavailable, log the fact at level 0. */
2238 if (!ServicePtrs[iService]->bAvailable)
2239 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2240 ServicePtrs[iService]->szService));
2242 return (bRetval);
2245 static struct file_lists
2247 struct file_lists *next;
2248 char *name;
2249 char *subfname;
2250 time_t modtime;
2251 } *file_lists = NULL;
2253 /*******************************************************************
2254 keep a linked list of all config files so we know when one has changed
2255 it's date and needs to be reloaded
2256 ********************************************************************/
2257 static void add_to_file_list(char *fname, char *subfname)
2259 struct file_lists *f = file_lists;
2261 while (f) {
2262 if (f->name && !strcmp(f->name, fname))
2263 break;
2264 f = f->next;
2267 if (!f) {
2268 f = (struct file_lists *)malloc(sizeof(file_lists[0]));
2269 if (!f)
2270 return;
2271 f->next = file_lists;
2272 f->name = strdup(fname);
2273 if (!f->name) {
2274 SAFE_FREE(f);
2275 return;
2277 f->subfname = strdup(subfname);
2278 if (!f->subfname) {
2279 SAFE_FREE(f);
2280 return;
2282 file_lists = f;
2283 f->modtime = file_modtime(subfname);
2284 } else {
2285 time_t t = file_modtime(subfname);
2286 if (t)
2287 f->modtime = t;
2291 /*******************************************************************
2292 check if a config file has changed date
2293 ********************************************************************/
2294 BOOL lp_file_list_changed(void)
2296 struct file_lists *f = file_lists;
2297 DEBUG(6, ("lp_file_list_changed()\n"));
2299 while (f) {
2300 pstring n2;
2301 time_t mod_time;
2303 pstrcpy(n2, f->name);
2304 standard_sub_basic(n2,sizeof(n2));
2306 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2307 f->name, n2, ctime(&f->modtime)));
2309 mod_time = file_modtime(n2);
2311 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2312 DEBUGADD(6, ("file %s modified: %s\n", n2, ctime(&mod_time)));
2313 f->modtime = mod_time;
2314 SAFE_FREE(f->subfname);
2315 f->subfname = strdup(n2);
2316 return (True);
2318 f = f->next;
2320 return (False);
2323 /***************************************************************************
2324 Run standard_sub_basic on netbios name... needed because global_myname
2325 is not accessed through any lp_ macro.
2326 Note: We must *NOT* use string_set() here as ptr points to global_myname.
2327 ***************************************************************************/
2329 static BOOL handle_netbios_name(char *pszParmValue, char **ptr)
2331 pstring netbios_name;
2333 pstrcpy(netbios_name, pszParmValue);
2335 standard_sub_basic(netbios_name,sizeof(netbios_name));
2336 strupper(netbios_name);
2339 * Convert from UNIX to DOS string - the UNIX to DOS converter
2340 * isn't called on the special handlers.
2342 unix_to_dos(netbios_name);
2343 pstrcpy(global_myname, netbios_name);
2345 DEBUG(4,
2346 ("handle_netbios_name: set global_myname to: %s\n",
2347 global_myname));
2349 return (True);
2352 /***************************************************************************
2353 Do the work of sourcing in environment variable/value pairs.
2354 ***************************************************************************/
2356 static BOOL source_env(char **lines)
2358 char *varval;
2359 size_t len;
2360 int i;
2361 char *p;
2363 for (i = 0; lines[i]; i++)
2365 char *line = lines[i];
2367 if ((len = strlen(line)) == 0)
2368 continue;
2370 if (line[len - 1] == '\n')
2371 line[--len] = '\0';
2373 if ((varval = malloc(len + 1)) == NULL)
2375 DEBUG(0, ("source_env: Not enough memory!\n"));
2376 return (False);
2379 DEBUG(4, ("source_env: Adding to environment: %s\n", line));
2380 strncpy(varval, line, len);
2381 varval[len] = '\0';
2383 p = strchr(line, (int)'=');
2384 if (p == NULL)
2386 DEBUG(4, ("source_env: missing '=': %s\n", line));
2387 continue;
2390 if (putenv(varval))
2392 DEBUG(0,
2393 ("source_env: Failed to put environment variable %s\n",
2394 varval));
2395 continue;
2398 *p = '\0';
2399 p++;
2400 DEBUG(4,
2401 ("source_env: getting var %s = %s\n", line,
2402 getenv(line)));
2405 DEBUG(4, ("source_env: returning successfully\n"));
2406 return (True);
2409 /***************************************************************************
2410 Handle the source environment operation
2411 ***************************************************************************/
2413 static BOOL handle_source_env(char *pszParmValue, char **ptr)
2415 pstring fname;
2416 char *p = fname;
2417 BOOL result;
2418 char **lines;
2420 pstrcpy(fname, pszParmValue);
2422 standard_sub_basic(fname,sizeof(fname));
2424 string_set(ptr, pszParmValue);
2426 DEBUG(4, ("handle_source_env: checking env type\n"));
2429 * Filename starting with '|' means popen and read from stdin.
2432 if (*p == '|')
2434 lines = file_lines_pload(p + 1, NULL, True);
2436 else
2438 lines = file_lines_load(fname, NULL, True);
2441 if (!lines)
2443 DEBUG(0,
2444 ("handle_source_env: Failed to open file %s, Error was %s\n",
2445 fname, strerror(errno)));
2446 return (False);
2449 result = source_env(lines);
2450 file_lines_free(lines);
2452 return (result);
2455 /***************************************************************************
2456 handle the interpretation of the vfs object parameter
2457 *************************************************************************/
2458 static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
2460 /* Set string value */
2462 string_set(ptr, pszParmValue);
2464 /* Do any other initialisation required for vfs. Note that
2465 anything done here may have linking repercussions in nmbd. */
2467 return True;
2470 /***************************************************************************
2471 handle the interpretation of the coding system parameter
2472 *************************************************************************/
2473 static BOOL handle_coding_system(char *pszParmValue, char **ptr)
2475 string_set(ptr, pszParmValue);
2476 interpret_coding_system(pszParmValue);
2477 return (True);
2480 /***************************************************************************
2481 Handle the interpretation of the character set system parameter.
2482 ***************************************************************************/
2484 static char *saved_character_set = NULL;
2486 static BOOL handle_character_set(char *pszParmValue, char **ptr)
2488 /* A dependency here is that the parameter client code page should be
2489 set before this is called.
2491 string_set(ptr, pszParmValue);
2492 strupper(*ptr);
2493 saved_character_set = strdup(*ptr);
2494 interpret_character_set(*ptr, lp_client_code_page());
2495 return (True);
2498 /***************************************************************************
2499 Handle the interpretation of the client code page parameter.
2500 We handle this separately so that we can reset the character set
2501 parameter in case this came before 'client code page' in the smb.conf.
2502 ***************************************************************************/
2504 static BOOL handle_client_code_page(char *pszParmValue, char **ptr)
2506 Globals.client_code_page = atoi(pszParmValue);
2507 if (saved_character_set != NULL)
2508 interpret_character_set(saved_character_set,
2509 lp_client_code_page());
2510 codepage_initialise(lp_client_code_page());
2511 return (True);
2514 /***************************************************************************
2515 handle the valid chars lines
2516 ***************************************************************************/
2518 static BOOL handle_valid_chars(char *pszParmValue, char **ptr)
2520 string_set(ptr, pszParmValue);
2522 /* A dependency here is that the parameter client code page must be
2523 set before this is called - as calling codepage_initialise()
2524 would overwrite the valid char lines.
2526 codepage_initialise(lp_client_code_page());
2528 add_char_string(pszParmValue);
2529 return (True);
2532 /***************************************************************************
2533 handle the include operation
2534 ***************************************************************************/
2536 static BOOL handle_include(char *pszParmValue, char **ptr)
2538 pstring fname;
2539 pstrcpy(fname, pszParmValue);
2541 standard_sub_basic(fname,sizeof(fname));
2543 add_to_file_list(pszParmValue, fname);
2545 string_set(ptr, fname);
2547 if (file_exist(fname, NULL))
2548 return (pm_process(fname, do_section, do_parameter));
2550 DEBUG(2, ("Can't find include file %s\n", fname));
2552 return (False);
2556 /***************************************************************************
2557 handle the interpretation of the copy parameter
2558 ***************************************************************************/
2559 static BOOL handle_copy(char *pszParmValue, char **ptr)
2561 BOOL bRetval;
2562 int iTemp;
2563 service serviceTemp;
2565 string_set(ptr, pszParmValue);
2567 init_service(&serviceTemp);
2569 bRetval = False;
2571 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2573 if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0)
2575 if (iTemp == iServiceIndex)
2577 DEBUG(0,
2578 ("Can't copy service %s - unable to copy self!\n",
2579 pszParmValue));
2581 else
2583 copy_service(ServicePtrs[iServiceIndex],
2584 &serviceTemp,
2585 ServicePtrs[iServiceIndex]->copymap);
2586 bRetval = True;
2589 else
2591 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2592 pszParmValue));
2593 bRetval = False;
2596 free_service(&serviceTemp);
2597 return (bRetval);
2600 /***************************************************************************
2601 Handle winbind uid and gid allocation parameters. The format of these
2602 parameters is:
2604 [global]
2606 winbind uid = 1000-1999
2607 winbind gid = 700-899
2609 We only do simple parsing checks here. The strings are parsed into useful
2610 structures in the winbind daemon code.
2612 ***************************************************************************/
2614 /* Some lp_ routines to return winbind [ug]id information */
2616 static uid_t winbind_uid_low, winbind_uid_high;
2617 static gid_t winbind_gid_low, winbind_gid_high;
2619 BOOL lp_winbind_uid(uid_t *low, uid_t *high)
2621 if (winbind_uid_low == 0 || winbind_uid_high == 0)
2622 return False;
2624 if (low)
2625 *low = winbind_uid_low;
2627 if (high)
2628 *high = winbind_uid_high;
2630 return True;
2633 BOOL lp_winbind_gid(gid_t *low, gid_t *high)
2635 if (winbind_gid_low == 0 || winbind_gid_high == 0)
2636 return False;
2638 if (low)
2639 *low = winbind_gid_low;
2641 if (high)
2642 *high = winbind_gid_high;
2644 return True;
2647 /* Do some simple checks on "winbind [ug]id" parameter values */
2649 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr)
2651 unsigned int low, high;
2653 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2654 return False;
2656 /* Parse OK */
2658 string_set(ptr, pszParmValue);
2660 winbind_uid_low = (uid_t)low;
2661 winbind_uid_high = (uid_t)high;
2663 return True;
2666 static BOOL handle_winbind_gid(char *pszParmValue, char **ptr)
2668 unsigned int low, high;
2670 if (sscanf(pszParmValue, "%u-%u", &low, &high) != 2 || high < low)
2671 return False;
2673 /* Parse OK */
2675 string_set(ptr, pszParmValue);
2677 winbind_gid_low = (gid_t)low;
2678 winbind_gid_high = (gid_t)high;
2680 return True;
2683 /***************************************************************************
2684 Handle the WINS SERVER list.
2685 ***************************************************************************/
2687 static BOOL handle_wins_server_list( char *pszParmValue, char **ptr )
2689 if( !wins_srv_load_list( pszParmValue ) )
2690 return( False ); /* Parse failed. */
2692 string_set( ptr, pszParmValue );
2693 return( True );
2696 /***************************************************************************
2697 Handle the DEBUG level list.
2698 ***************************************************************************/
2700 static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
2702 pstring pszParmValue;
2704 pstrcpy(pszParmValue, pszParmValueIn);
2705 return debug_parse_levels( pszParmValue );
2709 /***************************************************************************
2710 Initialise a copymap.
2711 ***************************************************************************/
2713 static void init_copymap(service * pservice)
2715 int i;
2716 SAFE_FREE(pservice->copymap);
2717 pservice->copymap = (BOOL *)malloc(sizeof(BOOL) * NUMPARAMETERS);
2718 if (!pservice->copymap)
2719 DEBUG(0,
2720 ("Couldn't allocate copymap!! (size %d)\n",
2721 (int)NUMPARAMETERS));
2722 else
2723 for (i = 0; i < NUMPARAMETERS; i++)
2724 pservice->copymap[i] = True;
2728 /***************************************************************************
2729 return the local pointer to a parameter given the service number and the
2730 pointer into the default structure
2731 ***************************************************************************/
2732 void *lp_local_ptr(int snum, void *ptr)
2734 return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
2737 /***************************************************************************
2738 Process a parameter for a particular service number. If snum < 0
2739 then assume we are in the globals
2740 ***************************************************************************/
2741 BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
2743 int parmnum, i;
2744 void *parm_ptr = NULL; /* where we are going to store the result */
2745 void *def_ptr = NULL;
2747 parmnum = map_parameter(pszParmName);
2749 if (parmnum < 0)
2751 DEBUG(0,
2752 ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2753 return (True);
2756 if (parm_table[parmnum].flags & FLAG_DEPRECATED)
2758 DEBUG(0, ("WARNING: The \"%s\"option is deprecated\n",
2759 pszParmName));
2762 def_ptr = parm_table[parmnum].ptr;
2764 /* we might point at a service, the default service or a global */
2765 if (snum < 0)
2767 parm_ptr = def_ptr;
2769 else
2771 if (parm_table[parmnum].class == P_GLOBAL)
2773 DEBUG(0,
2774 ("Global parameter %s found in service section!\n",
2775 pszParmName));
2776 return (True);
2778 parm_ptr =
2779 ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
2780 &sDefault);
2783 if (snum >= 0)
2785 if (!ServicePtrs[snum]->copymap)
2786 init_copymap(ServicePtrs[snum]);
2788 /* this handles the aliases - set the copymap for other entries with
2789 the same data pointer */
2790 for (i = 0; parm_table[i].label; i++)
2791 if (parm_table[i].ptr == parm_table[parmnum].ptr)
2792 ServicePtrs[snum]->copymap[i] = False;
2795 /* if it is a special case then go ahead */
2796 if (parm_table[parmnum].special)
2798 parm_table[parmnum].special(pszParmValue, (char **)parm_ptr);
2799 return (True);
2802 /* now switch on the type of variable it is */
2803 switch (parm_table[parmnum].type)
2805 case P_BOOL:
2806 set_boolean(parm_ptr, pszParmValue);
2807 break;
2809 case P_BOOLREV:
2810 set_boolean(parm_ptr, pszParmValue);
2811 *(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
2812 break;
2814 case P_INTEGER:
2815 *(int *)parm_ptr = atoi(pszParmValue);
2816 break;
2818 case P_CHAR:
2819 *(char *)parm_ptr = *pszParmValue;
2820 break;
2822 case P_OCTAL:
2823 sscanf(pszParmValue, "%o", (int *)parm_ptr);
2824 break;
2826 case P_STRING:
2827 string_set(parm_ptr, pszParmValue);
2828 if (parm_table[parmnum].flags & FLAG_DOS_STRING)
2829 unix_to_dos(*(char **)parm_ptr);
2830 break;
2832 case P_USTRING:
2833 string_set(parm_ptr, pszParmValue);
2834 if (parm_table[parmnum].flags & FLAG_DOS_STRING)
2835 unix_to_dos(*(char **)parm_ptr);
2836 strupper(*(char **)parm_ptr);
2837 break;
2839 case P_GSTRING:
2840 pstrcpy((char *)parm_ptr, pszParmValue);
2841 if (parm_table[parmnum].flags & FLAG_DOS_STRING)
2842 unix_to_dos((char *)parm_ptr);
2843 break;
2845 case P_UGSTRING:
2846 pstrcpy((char *)parm_ptr, pszParmValue);
2847 if (parm_table[parmnum].flags & FLAG_DOS_STRING)
2848 unix_to_dos((char *)parm_ptr);
2849 strupper((char *)parm_ptr);
2850 break;
2852 case P_ENUM:
2853 for (i = 0; parm_table[parmnum].enum_list[i].name;
2854 i++)
2856 if (strequal
2857 (pszParmValue,
2858 parm_table[parmnum].enum_list[i].name))
2860 *(int *)parm_ptr =
2861 parm_table[parmnum].
2862 enum_list[i].value;
2863 break;
2866 break;
2867 case P_SEP:
2868 break;
2872 return (True);
2875 /***************************************************************************
2876 Process a parameter.
2877 ***************************************************************************/
2878 static BOOL do_parameter(char *pszParmName, char *pszParmValue)
2880 if (!bInGlobalSection && bGlobalOnly)
2881 return (True);
2883 DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue));
2885 return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
2886 pszParmName, pszParmValue));
2890 /***************************************************************************
2891 print a parameter of the specified type
2892 ***************************************************************************/
2893 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f, char *(*dos_to_ext)(const char *))
2895 int i;
2896 switch (p->type)
2898 case P_ENUM:
2899 for (i = 0; p->enum_list[i].name; i++)
2901 if (*(int *)ptr == p->enum_list[i].value)
2903 fprintf(f, "%s",
2904 p->enum_list[i].name);
2905 break;
2908 break;
2910 case P_BOOL:
2911 fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
2912 break;
2914 case P_BOOLREV:
2915 fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
2916 break;
2918 case P_INTEGER:
2919 fprintf(f, "%d", *(int *)ptr);
2920 if (strequal(p->label,"log level")) {
2921 for (i = 1; i < DBGC_LAST; i ++) {
2922 if (((int *)ptr)[i])
2923 fprintf(f, ",%s:%d",debug_classname_from_index(i),((int *)ptr)[i]);
2926 break;
2928 case P_CHAR:
2929 fprintf(f, "%c", *(char *)ptr);
2930 break;
2932 case P_OCTAL:
2933 fprintf(f, "%s", octal_string(*(int *)ptr));
2934 break;
2936 case P_GSTRING:
2937 case P_UGSTRING:
2938 if ((char *)ptr) {
2939 if (p->flags & FLAG_DOS_STRING)
2940 fprintf(f, "%s", dos_to_ext((const char *)ptr));
2941 else
2942 fprintf(f, "%s", (char *)ptr);
2944 break;
2946 case P_STRING:
2947 case P_USTRING:
2948 if (*(char **)ptr) {
2949 if(p->flags & FLAG_DOS_STRING)
2950 fprintf(f,"%s",dos_to_ext((const char *)*(const char **)ptr));
2951 else
2952 fprintf(f, "%s", *(char **)ptr);
2954 break;
2955 case P_SEP:
2956 break;
2961 /***************************************************************************
2962 check if two parameters are equal
2963 ***************************************************************************/
2964 static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
2966 switch (type)
2968 case P_BOOL:
2969 case P_BOOLREV:
2970 return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
2972 case P_INTEGER:
2973 case P_ENUM:
2974 case P_OCTAL:
2975 return (*((int *)ptr1) == *((int *)ptr2));
2977 case P_CHAR:
2978 return (*((char *)ptr1) == *((char *)ptr2));
2980 case P_GSTRING:
2981 case P_UGSTRING:
2983 char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
2984 if (p1 && !*p1)
2985 p1 = NULL;
2986 if (p2 && !*p2)
2987 p2 = NULL;
2988 return (p1 == p2 || strequal(p1, p2));
2990 case P_STRING:
2991 case P_USTRING:
2993 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
2994 if (p1 && !*p1)
2995 p1 = NULL;
2996 if (p2 && !*p2)
2997 p2 = NULL;
2998 return (p1 == p2 || strequal(p1, p2));
3000 case P_SEP:
3001 break;
3003 return (False);
3006 /***************************************************************************
3007 Initialize any local varients in the sDefault table.
3008 ***************************************************************************/
3010 void init_locals(void)
3012 /* None as yet. */
3015 /***************************************************************************
3016 Process a new section (service). At this stage all sections are services.
3017 Later we'll have special sections that permit server parameters to be set.
3018 Returns True on success, False on failure. SectionName must be in DOS codepage.
3019 ***************************************************************************/
3020 static BOOL do_section(char *pszSectionName)
3022 BOOL bRetval;
3023 BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3024 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3025 bRetval = False;
3027 /* if we were in a global section then do the local inits */
3028 if (bInGlobalSection && !isglobal)
3029 init_locals();
3031 /* if we've just struck a global section, note the fact. */
3032 bInGlobalSection = isglobal;
3034 /* check for multiple global sections */
3035 if (bInGlobalSection)
3037 DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
3038 return (True);
3041 if (!bInGlobalSection && bGlobalOnly)
3042 return (True);
3044 /* if we have a current service, tidy it up before moving on */
3045 bRetval = True;
3047 if (iServiceIndex >= 0)
3048 bRetval = service_ok(iServiceIndex);
3050 /* if all is still well, move to the next record in the services array */
3051 if (bRetval)
3053 /* We put this here to avoid an odd message order if messages are */
3054 /* issued by the post-processing of a previous section. */
3055 DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
3057 if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
3058 < 0)
3060 DEBUG(0, ("Failed to add a new service\n"));
3061 return (False);
3065 return (bRetval);
3069 /***************************************************************************
3070 determine if a partcular base parameter is currently set to the default value.
3071 ***************************************************************************/
3072 static BOOL is_default(int i)
3074 if (!defaults_saved)
3075 return False;
3076 switch (parm_table[i].type)
3078 case P_STRING:
3079 case P_USTRING:
3080 return strequal(parm_table[i].def.svalue,
3081 *(char **)parm_table[i].ptr);
3082 case P_GSTRING:
3083 case P_UGSTRING:
3084 return strequal(parm_table[i].def.svalue,
3085 (char *)parm_table[i].ptr);
3086 case P_BOOL:
3087 case P_BOOLREV:
3088 return parm_table[i].def.bvalue ==
3089 *(BOOL *)parm_table[i].ptr;
3090 case P_CHAR:
3091 return parm_table[i].def.cvalue ==
3092 *(char *)parm_table[i].ptr;
3093 case P_INTEGER:
3094 case P_OCTAL:
3095 case P_ENUM:
3096 return parm_table[i].def.ivalue ==
3097 *(int *)parm_table[i].ptr;
3098 case P_SEP:
3099 break;
3101 return False;
3105 /***************************************************************************
3106 Display the contents of the global structure.
3107 ***************************************************************************/
3108 static void dump_globals(FILE *f, char *(*dos_to_ext)(const char *))
3110 int i;
3111 fprintf(f, "# Global parameters\n[global]\n");
3113 for (i = 0; parm_table[i].label; i++)
3114 if (parm_table[i].class == P_GLOBAL &&
3115 parm_table[i].ptr &&
3116 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3118 if (defaults_saved && is_default(i))
3119 continue;
3120 fprintf(f, "\t%s = ", parm_table[i].label);
3121 print_parameter(&parm_table[i], parm_table[i].ptr, f, dos_to_ext);
3122 fprintf(f, "\n");
3126 /***************************************************************************
3127 return True if a local parameter is currently set to the global default
3128 ***************************************************************************/
3129 BOOL lp_is_default(int snum, struct parm_struct *parm)
3131 int pdiff = PTR_DIFF(parm->ptr, &sDefault);
3133 return equal_parameter(parm->type,
3134 ((char *)ServicePtrs[snum]) + pdiff,
3135 ((char *)&sDefault) + pdiff);
3139 /***************************************************************************
3140 Display the contents of a single services record.
3141 ***************************************************************************/
3142 static void dump_a_service(service * pService, FILE * f, char *(*dos_to_ext)(const char *))
3144 int i;
3145 if (pService != &sDefault)
3146 fprintf(f, "\n[%s]\n", pService->szService);
3148 for (i = 0; parm_table[i].label; i++)
3149 if (parm_table[i].class == P_LOCAL &&
3150 parm_table[i].ptr &&
3151 (*parm_table[i].label != '-') &&
3152 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3154 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
3156 if (pService == &sDefault)
3158 if (defaults_saved && is_default(i))
3159 continue;
3161 else
3163 if (equal_parameter(parm_table[i].type,
3164 ((char *)pService) +
3165 pdiff,
3166 ((char *)&sDefault) +
3167 pdiff))
3168 continue;
3171 fprintf(f, "\t%s = ", parm_table[i].label);
3172 print_parameter(&parm_table[i],
3173 ((char *)pService) + pdiff, f, dos_to_ext);
3174 fprintf(f, "\n");
3179 /***************************************************************************
3180 return info about the next service in a service. snum==-1 gives the globals
3182 return NULL when out of parameters
3183 ***************************************************************************/
3184 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
3186 if (snum == -1)
3188 /* do the globals */
3189 for (; parm_table[*i].label; (*i)++)
3191 if (parm_table[*i].class == P_SEPARATOR)
3192 return &parm_table[(*i)++];
3194 if (!parm_table[*i].ptr
3195 || (*parm_table[*i].label == '-'))
3196 continue;
3198 if ((*i) > 0
3199 && (parm_table[*i].ptr ==
3200 parm_table[(*i) - 1].ptr))
3201 continue;
3203 return &parm_table[(*i)++];
3206 else
3208 service *pService = ServicePtrs[snum];
3210 for (; parm_table[*i].label; (*i)++)
3212 if (parm_table[*i].class == P_SEPARATOR)
3213 return &parm_table[(*i)++];
3215 if (parm_table[*i].class == P_LOCAL &&
3216 parm_table[*i].ptr &&
3217 (*parm_table[*i].label != '-') &&
3218 ((*i) == 0 ||
3219 (parm_table[*i].ptr !=
3220 parm_table[(*i) - 1].ptr)))
3222 int pdiff =
3223 PTR_DIFF(parm_table[*i].ptr,
3224 &sDefault);
3226 if (allparameters ||
3227 !equal_parameter(parm_table[*i].type,
3228 ((char *)pService) +
3229 pdiff,
3230 ((char *)&sDefault) +
3231 pdiff))
3233 return &parm_table[(*i)++];
3239 return NULL;
3243 #if 0
3244 /***************************************************************************
3245 Display the contents of a single copy structure.
3246 ***************************************************************************/
3247 static void dump_copy_map(BOOL *pcopymap)
3249 int i;
3250 if (!pcopymap)
3251 return;
3253 printf("\n\tNon-Copied parameters:\n");
3255 for (i = 0; parm_table[i].label; i++)
3256 if (parm_table[i].class == P_LOCAL &&
3257 parm_table[i].ptr && !pcopymap[i] &&
3258 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
3260 printf("\t\t%s\n", parm_table[i].label);
3263 #endif
3265 /***************************************************************************
3266 Return TRUE if the passed service number is within range.
3267 ***************************************************************************/
3269 BOOL lp_snum_ok(int iService)
3271 return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
3274 /***************************************************************************
3275 Auto-load some home services.
3276 ***************************************************************************/
3278 static void lp_add_auto_services(char *str)
3280 char *s;
3281 char *p;
3282 int homes;
3284 if (!str)
3285 return;
3287 s = strdup(str);
3288 if (!s)
3289 return;
3291 homes = lp_servicenumber(HOMES_NAME);
3293 for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
3294 char *home = get_user_service_home_dir(p);
3296 if (lp_servicenumber(p) >= 0)
3297 continue;
3299 if (home && homes >= 0)
3300 lp_add_home(p, homes, home);
3302 SAFE_FREE(s);
3305 /***************************************************************************
3306 Auto-load one printer.
3307 ***************************************************************************/
3309 void lp_add_one_printer(char *name, char *comment)
3311 int printers = lp_servicenumber(PRINTERS_NAME);
3312 int i;
3314 if (lp_servicenumber(name) < 0) {
3315 lp_add_printer(name, printers);
3316 if ((i = lp_servicenumber(name)) >= 0) {
3317 string_set(&ServicePtrs[i]->comment, comment);
3318 unix_to_dos(ServicePtrs[i]->comment);
3319 ServicePtrs[i]->autoloaded = True;
3324 /***************************************************************************
3325 have we loaded a services file yet?
3326 ***************************************************************************/
3327 BOOL lp_loaded(void)
3329 return (bLoaded);
3332 /***************************************************************************
3333 unload unused services
3334 ***************************************************************************/
3335 void lp_killunused(BOOL (*snumused) (int))
3337 int i;
3338 for (i = 0; i < iNumServices; i++)
3340 if (!VALID(i))
3341 continue;
3343 if (!snumused || !snumused(i))
3345 ServicePtrs[i]->valid = False;
3346 free_service(ServicePtrs[i]);
3352 /***************************************************************************
3353 unload a service
3354 ***************************************************************************/
3355 void lp_killservice(int iServiceIn)
3357 if (VALID(iServiceIn))
3359 ServicePtrs[iServiceIn]->valid = False;
3360 free_service(ServicePtrs[iServiceIn]);
3364 /***************************************************************************
3365 save the curent values of all global and sDefault parameters into the
3366 defaults union. This allows swat and testparm to show only the
3367 changed (ie. non-default) parameters.
3368 ***************************************************************************/
3369 static void lp_save_defaults(void)
3371 int i;
3372 for (i = 0; parm_table[i].label; i++)
3374 if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
3375 continue;
3376 switch (parm_table[i].type)
3378 case P_STRING:
3379 case P_USTRING:
3380 parm_table[i].def.svalue =
3381 strdup(*(char **)parm_table[i].ptr);
3382 break;
3383 case P_GSTRING:
3384 case P_UGSTRING:
3385 parm_table[i].def.svalue =
3386 strdup((char *)parm_table[i].ptr);
3387 break;
3388 case P_BOOL:
3389 case P_BOOLREV:
3390 parm_table[i].def.bvalue =
3391 *(BOOL *)parm_table[i].ptr;
3392 break;
3393 case P_CHAR:
3394 parm_table[i].def.cvalue =
3395 *(char *)parm_table[i].ptr;
3396 break;
3397 case P_INTEGER:
3398 case P_OCTAL:
3399 case P_ENUM:
3400 parm_table[i].def.ivalue =
3401 *(int *)parm_table[i].ptr;
3402 break;
3403 case P_SEP:
3404 break;
3407 defaults_saved = True;
3410 /*******************************************************************
3411 Set the server type we will announce as via nmbd.
3412 ********************************************************************/
3413 static void set_server_role(void)
3415 server_role = ROLE_STANDALONE;
3417 switch (lp_security()) {
3418 case SEC_SHARE:
3419 if (lp_domain_logons())
3420 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
3421 DEBUG(10,("set_server_role: ROLE_STANDALONE\n"));
3422 break;
3423 case SEC_SERVER:
3424 case SEC_DOMAIN:
3425 if (lp_domain_logons()) {
3426 server_role = ROLE_DOMAIN_BDC;
3427 DEBUG(10,("set_server_role: ROLE_DOMAIN_BDC\n"));
3428 break;
3430 server_role = ROLE_DOMAIN_MEMBER;
3431 DEBUG(10,("set_server_role: ROLE_DOMAIN_MEMBER\n"));
3432 break;
3433 case SEC_USER:
3434 if (lp_domain_logons()) {
3435 server_role = ROLE_DOMAIN_PDC;
3436 DEBUG(10,("set_server_role: ROLE_DOMAIN_PDC\n"));
3437 break;
3439 DEBUG(10,("set_server_role: ROLE_STANDALONE\n"));
3440 break;
3441 default:
3442 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
3443 DEBUG(10,("set_server_role: ROLE_STANDALONE\n"));
3444 break;
3449 /***************************************************************************
3450 Load the services array from the services file. Return True on success,
3451 False on failure.
3452 ***************************************************************************/
3453 BOOL lp_load(char *pszFname, BOOL global_only, BOOL save_defaults,
3454 BOOL add_ipc)
3456 pstring n2;
3457 BOOL bRetval;
3459 pstrcpy(n2, pszFname);
3460 standard_sub_basic(n2,sizeof(n2));
3462 add_to_file_list(pszFname, n2);
3464 bRetval = False;
3466 bInGlobalSection = True;
3467 bGlobalOnly = global_only;
3469 init_globals();
3471 if (save_defaults)
3473 init_locals();
3474 lp_save_defaults();
3477 pstrcpy(n2, pszFname);
3478 standard_sub_basic(n2,sizeof(n2));
3480 /* We get sections first, so have to start 'behind' to make up */
3481 iServiceIndex = -1;
3482 bRetval = pm_process(n2, do_section, do_parameter);
3484 /* finish up the last section */
3485 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
3486 if (bRetval)
3487 if (iServiceIndex >= 0)
3488 bRetval = service_ok(iServiceIndex);
3490 lp_add_auto_services(lp_auto_services());
3492 if (add_ipc) {
3493 lp_add_ipc("IPC$", True);
3494 lp_add_ipc("ADMIN$", False);
3497 set_server_role();
3498 set_default_server_announce_type();
3500 bLoaded = True;
3502 /* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
3503 /* if bWINSsupport is true and we are in the client */
3505 if (in_client && Globals.bWINSsupport)
3508 string_set(&Globals.szWINSserver, "127.0.0.1");
3512 return (bRetval);
3516 /***************************************************************************
3517 reset the max number of services
3518 ***************************************************************************/
3519 void lp_resetnumservices(void)
3521 iNumServices = 0;
3524 /***************************************************************************
3525 return the max number of services
3526 ***************************************************************************/
3527 int lp_numservices(void)
3529 return (iNumServices);
3532 /***************************************************************************
3533 Display the contents of the services array in human-readable form.
3534 ***************************************************************************/
3535 void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint, char *(*dos_to_ext)(const char *))
3537 int iService;
3539 if (show_defaults)
3541 defaults_saved = False;
3544 dump_globals(f, dos_to_ext);
3546 dump_a_service(&sDefault, f, dos_to_ext);
3548 for (iService = 0; iService < maxtoprint; iService++)
3549 lp_dump_one(f, show_defaults, iService, dos_to_ext);
3552 /***************************************************************************
3553 Display the contents of one service in human-readable form.
3554 ***************************************************************************/
3555 void lp_dump_one(FILE * f, BOOL show_defaults, int snum, char *(*dos_to_ext)(const char *))
3557 if (VALID(snum))
3559 if (ServicePtrs[snum]->szService[0] == '\0')
3560 return;
3561 dump_a_service(ServicePtrs[snum], f, dos_to_ext);
3566 /***************************************************************************
3567 Return the number of the service with the given name, or -1 if it doesn't
3568 exist. Note that this is a DIFFERENT ANIMAL from the internal function
3569 getservicebyname()! This works ONLY if all services have been loaded, and
3570 does not copy the found service.
3571 ***************************************************************************/
3572 int lp_servicenumber(char *pszServiceName)
3574 int iService;
3575 fstring serviceName;
3578 for (iService = iNumServices - 1; iService >= 0; iService--)
3580 if (VALID(iService) && ServicePtrs[iService]->szService)
3583 * The substitution here is used to support %U is
3584 * service names
3586 fstrcpy(serviceName, ServicePtrs[iService]->szService);
3587 standard_sub_basic(serviceName,sizeof(serviceName));
3588 if (strequal(serviceName, pszServiceName))
3589 break;
3593 if (iService < 0)
3594 DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
3596 return (iService);
3599 /*******************************************************************
3600 A useful volume label function. Returns a string in DOS codepage.
3601 ********************************************************************/
3603 char *volume_label(int snum)
3605 char *ret = lp_volume(snum);
3606 if (!*ret)
3607 return lp_servicename(snum);
3608 return (ret);
3612 /*******************************************************************
3613 Set the server type we will announce as via nmbd.
3614 ********************************************************************/
3615 static void set_default_server_announce_type(void)
3617 default_server_announce = 0;
3618 default_server_announce |= SV_TYPE_WORKSTATION;
3619 default_server_announce |= SV_TYPE_SERVER;
3620 default_server_announce |= SV_TYPE_SERVER_UNIX;
3621 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
3623 switch (lp_announce_as())
3625 case ANNOUNCE_AS_NT_SERVER:
3627 default_server_announce |= SV_TYPE_SERVER_NT;
3628 /* fall through... */
3630 case ANNOUNCE_AS_NT_WORKSTATION:
3632 default_server_announce |= SV_TYPE_NT;
3633 break;
3635 case ANNOUNCE_AS_WIN95:
3637 default_server_announce |= SV_TYPE_WIN95_PLUS;
3638 break;
3640 case ANNOUNCE_AS_WFW:
3642 default_server_announce |= SV_TYPE_WFW;
3643 break;
3645 default:
3647 break;
3651 switch (lp_server_role())
3653 case ROLE_DOMAIN_MEMBER:
3655 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
3656 break;
3658 case ROLE_DOMAIN_PDC:
3660 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
3661 break;
3663 case ROLE_DOMAIN_BDC:
3665 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
3666 break;
3668 case ROLE_STANDALONE:
3669 default:
3671 break;
3675 if (lp_time_server())
3677 default_server_announce |= SV_TYPE_TIME_SOURCE;
3680 if (lp_host_msdfs())
3682 default_server_announce |= SV_TYPE_DFS_SERVER;
3686 /***********************************************************
3687 returns role of Samba server
3688 ************************************************************/
3690 int lp_server_role(void)
3692 return server_role;
3695 /***********************************************************
3696 If we are PDC then prefer us as DMB
3697 ************************************************************/
3699 BOOL lp_domain_master(void)
3701 if (Globals.bDomainMaster == Auto)
3703 return (lp_server_role() == ROLE_DOMAIN_PDC);
3706 return Globals.bDomainMaster;
3709 /***********************************************************
3710 If we are DMB then prefer us as LMB
3711 ************************************************************/
3713 BOOL lp_preferred_master(void)
3715 if (Globals.bPreferredMaster == Auto)
3717 return (lp_local_master() && lp_domain_master());
3720 return Globals.bPreferredMaster;
3725 /*******************************************************************
3726 remove a service
3727 ********************************************************************/
3728 void lp_remove_service(int snum)
3730 ServicePtrs[snum]->valid = False;
3733 /*******************************************************************
3734 copy a service. new_name must be in dos codepage
3735 ********************************************************************/
3736 void lp_copy_service(int snum, char *new_name)
3738 char *oldname = lp_servicename(snum);
3739 do_section(new_name);
3740 if (snum >= 0)
3742 snum = lp_servicenumber(new_name);
3743 if (snum >= 0)
3744 lp_do_parameter(snum, "copy", oldname);
3749 /*******************************************************************
3750 Get the default server type we will announce as via nmbd.
3751 ********************************************************************/
3752 int lp_default_server_announce(void)
3754 return default_server_announce;
3757 /*******************************************************************
3758 Split the announce version into major and minor numbers.
3759 ********************************************************************/
3760 int lp_major_announce_version(void)
3762 static BOOL got_major = False;
3763 static int major_version = DEFAULT_MAJOR_VERSION;
3764 char *vers;
3765 char *p;
3767 if (got_major)
3768 return major_version;
3770 got_major = True;
3771 if ((vers = lp_announce_version()) == NULL)
3772 return major_version;
3774 if ((p = strchr(vers, '.')) == 0)
3775 return major_version;
3777 *p = '\0';
3778 major_version = atoi(vers);
3779 return major_version;
3782 int lp_minor_announce_version(void)
3784 static BOOL got_minor = False;
3785 static int minor_version = DEFAULT_MINOR_VERSION;
3786 char *vers;
3787 char *p;
3789 if (got_minor)
3790 return minor_version;
3792 got_minor = True;
3793 if ((vers = lp_announce_version()) == NULL)
3794 return minor_version;
3796 if ((p = strchr(vers, '.')) == 0)
3797 return minor_version;
3799 p++;
3800 minor_version = atoi(p);
3801 return minor_version;
3804 /***********************************************************
3805 Set the global name resolution order (used in smbclient).
3806 ************************************************************/
3808 void lp_set_name_resolve_order(char *new_order)
3810 Globals.szNameResolveOrder = new_order;
3813 char *lp_printername(int snum)
3815 char *ret = _lp_printername(snum);
3816 if (ret == NULL || (ret != NULL && *ret == '\0'))
3817 ret = lp_servicename(snum);
3819 return ret;
3822 /***********************************************************
3823 Return a pointer to the private directory (containing
3824 smbpasswd etc.).
3825 ************************************************************/
3827 void get_private_directory(pstring priv_dir)
3829 char *p;
3831 *priv_dir = 0;
3833 #ifdef WITH_TDB_SAM
3834 pstrcpy(priv_dir, lp_tdb_passwd_file());
3835 #else
3836 pstrcpy(priv_dir, lp_smb_passwd_file());
3837 #endif
3839 p = strrchr(priv_dir, '/');
3840 if (p) *p = 0;
3843 /***********************************************************
3844 Allow daemons such as winbindd to fix their logfile name.
3845 ************************************************************/
3847 void lp_set_logfile(const char *name)
3849 extern pstring debugf;
3850 string_set(&Globals.szLogFile, name);
3851 pstrcpy(debugf, name);
3854 /*******************************************************************
3855 Return the NetBIOS called name.
3856 ********************************************************************/
3858 const char *get_called_name(void)
3860 extern fstring local_machine;
3861 static fstring called_name;
3863 if (! *local_machine)
3864 return global_myname;
3867 * Windows NT/2k uses "*SMBSERVER" and XP uses "*SMBSERV"
3868 * arrggg!!! but we've already rewritten the client's
3869 * netbios name at this point...
3872 if (*local_machine) {
3873 if (!StrCaseCmp(local_machine, "_SMBSERVER") || !StrCaseCmp(local_machine, "_SMBSERV")) {
3874 fstrcpy(called_name, get_my_primary_ip());
3875 DEBUG(8,("get_called_name: assuming that client used IP address [%s] as called name.\n",
3876 called_name));
3877 return called_name;
3881 return local_machine;
3884 /*******************************************************************
3885 Return the max print jobs per queue.
3886 ********************************************************************/
3888 int lp_maxprintjobs(int snum)
3890 int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
3891 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
3892 maxjobs = PRINT_MAX_JOBID - 1;
3894 return maxjobs;