2 Unix SMB/Netbios implementation.
4 Parameter loading functions
5 Copyright (C) Karl Auer 1993,1997
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.
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.
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
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
52 /* Set default coding system for KANJI if none specified in Makefile. */
59 extern int DEBUGLEVEL
;
60 extern pstring user_socket_options
;
61 extern pstring myname
;
64 #define GLOBAL_NAME "global"
69 #define PRINTCAP_NAME "/etc/qconfig"
71 #define PRINTCAP_NAME "/etc/printcap"
76 #define PRINTERS_NAME "printers"
80 #define HOMES_NAME "homes"
83 /* some helpful bits */
84 #define pSERVICE(i) ServicePtrs[i]
85 #define iSERVICE(i) (*pSERVICE(i))
86 #define LP_SNUM_OK(iService) (((iService) >= 0) && ((iService) < iNumServices) && iSERVICE(iService).valid)
87 #define VALID(i) iSERVICE(i).valid
89 /* these are the types of parameter we have */
92 P_BOOL
,P_BOOLREV
,P_CHAR
,P_INTEGER
,P_OCTAL
,
93 P_STRING
,P_USTRING
,P_GSTRING
,P_UGSTRING
98 P_LOCAL
,P_GLOBAL
,P_NONE
102 extern BOOL use_getwd_cache
;
104 extern int extra_time_offset
;
105 extern int coding_system
;
108 * This structure describes global (ie., server-wide) parameters.
112 char *szPrintcapname
;
115 char *szDefaultService
;
119 char *szServerString
;
120 char *szAutoServices
;
121 char *szPasswdProgram
;
125 char *szSMBPasswdFile
;
126 char *szPasswordServer
;
127 char *szSocketOptions
;
130 char *szDomainAdminUsers
;
131 char *szDomainGuestUsers
;
132 char *szDomainHostsallow
;
133 char *szDomainHostsdeny
;
135 char *szCharacterSet
;
143 char *szRemoteAnnounce
;
144 char *szSocketAddress
;
145 char *szNISHomeMapName
;
146 char *szAnnounceVersion
; /* This is initialised in init_globals */
147 char *szNetbiosAliases
;
149 char *szDomainOtherSIDs
;
150 char *szDomainGroups
;
170 int client_code_page
;
171 int announce_as
; /* This is initialised in init_globals */
176 BOOL bPreferredMaster
;
177 BOOL bDomainController
;
180 BOOL bEncryptPasswords
;
187 BOOL bReadPrediction
;
194 BOOL bBindInterfacesOnly
;
197 static global Globals
;
202 * This structure describes a single service.
210 char *szGuestaccount
;
211 char *szInvalidUsers
;
219 char *szRootPostExec
;
220 char *szPrintcommand
;
223 char *szLppausecommand
;
224 char *szLpresumecommand
;
226 char *szPrinterDriver
;
227 char *szPrinterDriverLocation
;
236 char *szVetoOplockFiles
;
245 int iCreate_force_mode
;
254 BOOL bShortCasePreserve
;
280 BOOL bDeleteReadonly
;
282 BOOL bDeleteVetoFiles
;
284 char dummy
[3]; /* for alignment */
288 /* This is a default service used to prime a services structure */
289 static service sDefault
=
292 NULL
, /* szService */
294 NULL
, /* szUsername */
295 NULL
, /* szGuestAccount - this is set in init_globals() */
296 NULL
, /* szInvalidUsers */
297 NULL
, /* szValidUsers */
298 NULL
, /* szAdminUsers */
300 NULL
, /* szInclude */
301 NULL
, /* szPreExec */
302 NULL
, /* szPostExec */
303 NULL
, /* szRootPreExec */
304 NULL
, /* szRootPostExec */
305 NULL
, /* szPrintcommand */
306 NULL
, /* szLpqcommand */
307 NULL
, /* szLprmcommand */
308 NULL
, /* szLppausecommand */
309 NULL
, /* szLpresumecommand */
310 NULL
, /* szPrintername */
311 NULL
, /* szPrinterDriver - this is set in init_globals() */
312 NULL
, /* szPrinterDriverLocation */
313 NULL
, /* szDontdescend */
314 NULL
, /* szHostsallow */
315 NULL
, /* szHostsdeny */
316 NULL
, /* szMagicScript */
317 NULL
, /* szMagicOutput */
318 NULL
, /* szMangledMap */
319 NULL
, /* szVetoFiles */
320 NULL
, /* szHideFiles */
321 NULL
, /* szVetoOplockFiles */
323 NULL
, /* force user */
324 NULL
, /* force group */
326 NULL
, /* writelist */
328 0, /* iMinPrintSpace */
329 0744, /* iCreate_mask */
330 0000, /* iCreate_force_mode */
331 0755, /* iDir_mask */
332 0000, /* iDir_force_mode */
333 0, /* iMaxConnections */
334 CASE_LOWER
, /* iDefaultCase */
335 False
, /* bAlternatePerm */
336 False
, /* revalidate */
337 False
, /* case sensitive */
338 False
, /* case preserve */
339 False
, /* short case preserve */
340 False
, /* case mangle */
342 True
, /* bHideDotFiles */
343 True
, /* bBrowseable */
344 True
, /* bAvailable */
345 True
, /* bRead_only */
346 True
, /* bNo_set_dir */
347 False
, /* bGuest_only */
348 False
, /* bGuest_ok */
349 False
, /* bPrint_ok */
350 False
, /* bPostscript */
351 False
, /* bMap_system */
352 False
, /* bMap_hidden */
353 True
, /* bMap_archive */
355 False
, /* bStrictLocking */
356 True
, /* bShareModes */
358 False
, /* bOnlyUser */
359 True
, /* bMangledNames */
360 True
, /* bWidelinks */
361 True
, /* bSymlinks */
362 False
, /* bSyncAlways */
363 '~', /* magic char */
365 False
, /* bDeleteReadonly */
366 False
, /* bFakeOplocks */
367 False
, /* bDeleteVetoFiles */
368 False
, /* bDosFiletimes */
374 /* local variables */
375 static service
**ServicePtrs
= NULL
;
376 static int iNumServices
= 0;
377 static int iServiceIndex
= 0;
378 static BOOL bInGlobalSection
= True
;
379 static BOOL bGlobalOnly
= False
;
380 static int default_server_announce
;
382 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
384 /* prototypes for the special type handlers */
385 static BOOL
handle_valid_chars(char *pszParmValue
, char **ptr
);
386 static BOOL
handle_include(char *pszParmValue
, char **ptr
);
387 static BOOL
handle_copy(char *pszParmValue
, char **ptr
);
388 static BOOL
handle_protocol(char *pszParmValue
,int *val
);
389 static BOOL
handle_security(char *pszParmValue
,int *val
);
390 static BOOL
handle_case(char *pszParmValue
,int *val
);
391 static BOOL
handle_printing(char *pszParmValue
,int *val
);
392 static BOOL
handle_character_set(char *pszParmValue
,int *val
);
393 static BOOL
handle_announce_as(char *pszParmValue
, int *val
);
394 static BOOL
handle_coding_system(char *pszParmValue
,int *val
);
396 static void set_default_server_announce_type(void);
407 {"debuglevel", P_INTEGER
, P_GLOBAL
, &DEBUGLEVEL
, NULL
},
408 {"log level", P_INTEGER
, P_GLOBAL
, &DEBUGLEVEL
, NULL
},
409 {"syslog", P_INTEGER
, P_GLOBAL
, &Globals
.syslog
, NULL
},
410 {"syslog only", P_BOOL
, P_GLOBAL
, &Globals
.bSyslogOnly
, NULL
},
411 {"protocol", P_INTEGER
, P_GLOBAL
, &Globals
.maxprotocol
,handle_protocol
},
412 {"security", P_INTEGER
, P_GLOBAL
, &Globals
.security
,handle_security
},
413 {"printing", P_INTEGER
, P_GLOBAL
, &Globals
.printing
,handle_printing
},
414 {"max disk size", P_INTEGER
, P_GLOBAL
, &Globals
.maxdisksize
, NULL
},
415 {"lpq cache time", P_INTEGER
, P_GLOBAL
, &Globals
.lpqcachetime
, NULL
},
416 {"announce as", P_INTEGER
, P_GLOBAL
, &Globals
.announce_as
, handle_announce_as
},
417 {"encrypt passwords",P_BOOL
, P_GLOBAL
, &Globals
.bEncryptPasswords
, NULL
},
418 {"getwd cache", P_BOOL
, P_GLOBAL
, &use_getwd_cache
, NULL
},
419 {"read prediction", P_BOOL
, P_GLOBAL
, &Globals
.bReadPrediction
, NULL
},
420 {"read bmpx", P_BOOL
, P_GLOBAL
, &Globals
.bReadbmpx
, NULL
},
421 {"read raw", P_BOOL
, P_GLOBAL
, &Globals
.bReadRaw
, NULL
},
422 {"write raw", P_BOOL
, P_GLOBAL
, &Globals
.bWriteRaw
, NULL
},
423 {"use rhosts", P_BOOL
, P_GLOBAL
, &Globals
.bUseRhosts
, NULL
},
424 {"load printers", P_BOOL
, P_GLOBAL
, &Globals
.bLoadPrinters
, NULL
},
425 {"null passwords", P_BOOL
, P_GLOBAL
, &Globals
.bNullPasswords
, NULL
},
426 {"strip dot", P_BOOL
, P_GLOBAL
, &Globals
.bStripDot
, NULL
},
427 {"interfaces", P_STRING
, P_GLOBAL
, &Globals
.szInterfaces
, NULL
},
428 {"bind interfaces only", P_BOOL
,P_GLOBAL
, &Globals
.bBindInterfacesOnly
,NULL
},
429 {"password server", P_STRING
, P_GLOBAL
, &Globals
.szPasswordServer
, NULL
},
430 {"socket options", P_GSTRING
, P_GLOBAL
, user_socket_options
, NULL
},
431 {"netbios name", P_UGSTRING
,P_GLOBAL
, myname
, NULL
},
432 {"netbios aliases", P_STRING
, P_GLOBAL
, &Globals
.szNetbiosAliases
, NULL
},
433 {"smbrun", P_STRING
, P_GLOBAL
, &Globals
.szSmbrun
, NULL
},
434 {"log file", P_STRING
, P_GLOBAL
, &Globals
.szLogFile
, NULL
},
435 {"config file", P_STRING
, P_GLOBAL
, &Globals
.szConfigFile
, NULL
},
436 {"smb passwd file", P_STRING
, P_GLOBAL
, &Globals
.szSMBPasswdFile
, NULL
},
437 {"hosts equiv", P_STRING
, P_GLOBAL
, &Globals
.szHostsEquiv
, NULL
},
438 {"preload", P_STRING
, P_GLOBAL
, &Globals
.szAutoServices
, NULL
},
439 {"auto services", P_STRING
, P_GLOBAL
, &Globals
.szAutoServices
, NULL
},
440 {"server string", P_STRING
, P_GLOBAL
, &Globals
.szServerString
, NULL
},
441 {"printcap name", P_STRING
, P_GLOBAL
, &Globals
.szPrintcapname
, NULL
},
442 {"printcap", P_STRING
, P_GLOBAL
, &Globals
.szPrintcapname
, NULL
},
443 {"lock dir", P_STRING
, P_GLOBAL
, &Globals
.szLockDir
, NULL
},
444 {"lock directory", P_STRING
, P_GLOBAL
, &Globals
.szLockDir
, NULL
},
445 {"root directory", P_STRING
, P_GLOBAL
, &Globals
.szRootdir
, NULL
},
446 {"root dir", P_STRING
, P_GLOBAL
, &Globals
.szRootdir
, NULL
},
447 {"root", P_STRING
, P_GLOBAL
, &Globals
.szRootdir
, NULL
},
448 {"default service", P_STRING
, P_GLOBAL
, &Globals
.szDefaultService
, NULL
},
449 {"default", P_STRING
, P_GLOBAL
, &Globals
.szDefaultService
, NULL
},
450 {"message command", P_STRING
, P_GLOBAL
, &Globals
.szMsgCommand
, NULL
},
451 {"dfree command", P_STRING
, P_GLOBAL
, &Globals
.szDfree
, NULL
},
452 {"passwd program", P_STRING
, P_GLOBAL
, &Globals
.szPasswdProgram
, NULL
},
453 {"passwd chat", P_STRING
, P_GLOBAL
, &Globals
.szPasswdChat
, NULL
},
454 {"valid chars", P_STRING
, P_GLOBAL
, &Globals
.szValidChars
, handle_valid_chars
},
455 {"workgroup", P_USTRING
, P_GLOBAL
, &Globals
.szWorkGroup
, NULL
},
456 {"domain sid", P_USTRING
, P_GLOBAL
, &Globals
.szDomainSID
, NULL
},
457 {"domain other sids",P_STRING
, P_GLOBAL
, &Globals
.szDomainOtherSIDs
, NULL
},
458 {"domain groups", P_STRING
, P_GLOBAL
, &Globals
.szDomainGroups
, NULL
},
459 {"domain controller",P_BOOL
, P_GLOBAL
, &Globals
.bDomainController
,NULL
},
460 {"domain admin users",P_STRING
, P_GLOBAL
, &Globals
.szDomainAdminUsers
, NULL
},
461 {"domain guest users",P_STRING
, P_GLOBAL
, &Globals
.szDomainGuestUsers
, NULL
},
462 {"domain hosts allow",P_STRING
, P_GLOBAL
, &Globals
.szDomainHostsallow
, NULL
},
463 {"domain allow hosts",P_STRING
, P_GLOBAL
, &Globals
.szDomainHostsallow
, NULL
},
464 {"domain hosts deny", P_STRING
, P_GLOBAL
, &Globals
.szDomainHostsdeny
, NULL
},
465 {"domain deny hosts", P_STRING
, P_GLOBAL
, &Globals
.szDomainHostsdeny
, NULL
},
466 {"username map", P_STRING
, P_GLOBAL
, &Globals
.szUsernameMap
, NULL
},
467 {"character set", P_STRING
, P_GLOBAL
, &Globals
.szCharacterSet
, handle_character_set
},
468 {"logon script", P_STRING
, P_GLOBAL
, &Globals
.szLogonScript
, NULL
},
469 {"logon path", P_STRING
, P_GLOBAL
, &Globals
.szLogonPath
, NULL
},
470 {"logon drive", P_STRING
, P_GLOBAL
, &Globals
.szLogonDrive
, NULL
},
471 {"logon home", P_STRING
, P_GLOBAL
, &Globals
.szLogonHome
, NULL
},
472 {"remote announce", P_STRING
, P_GLOBAL
, &Globals
.szRemoteAnnounce
, NULL
},
473 {"socket address", P_STRING
, P_GLOBAL
, &Globals
.szSocketAddress
, NULL
},
474 {"homedir map", P_STRING
, P_GLOBAL
, &Globals
.szNISHomeMapName
, NULL
},
475 {"announce version", P_STRING
, P_GLOBAL
, &Globals
.szAnnounceVersion
, NULL
},
476 {"max log size", P_INTEGER
, P_GLOBAL
, &Globals
.max_log_size
, NULL
},
477 {"mangled stack", P_INTEGER
, P_GLOBAL
, &Globals
.mangled_stack
, NULL
},
478 {"max mux", P_INTEGER
, P_GLOBAL
, &Globals
.max_mux
, NULL
},
479 {"max xmit", P_INTEGER
, P_GLOBAL
, &Globals
.max_xmit
, NULL
},
480 {"max packet", P_INTEGER
, P_GLOBAL
, &Globals
.max_packet
, NULL
},
481 {"packet size", P_INTEGER
, P_GLOBAL
, &Globals
.max_packet
, NULL
},
482 {"password level", P_INTEGER
, P_GLOBAL
, &Globals
.pwordlevel
, NULL
},
483 {"username level", P_INTEGER
, P_GLOBAL
, &Globals
.unamelevel
, NULL
},
484 {"keepalive", P_INTEGER
, P_GLOBAL
, &keepalive
, NULL
},
485 {"deadtime", P_INTEGER
, P_GLOBAL
, &Globals
.deadtime
, NULL
},
486 {"time offset", P_INTEGER
, P_GLOBAL
, &extra_time_offset
, NULL
},
487 {"read size", P_INTEGER
, P_GLOBAL
, &Globals
.ReadSize
, NULL
},
488 {"shared mem size", P_INTEGER
, P_GLOBAL
, &Globals
.shmem_size
, NULL
},
489 {"coding system", P_INTEGER
, P_GLOBAL
, &coding_system
, handle_coding_system
},
490 {"client code page", P_INTEGER
, P_GLOBAL
, &Globals
.client_code_page
, NULL
},
491 {"os level", P_INTEGER
, P_GLOBAL
, &Globals
.os_level
, NULL
},
492 {"max ttl", P_INTEGER
, P_GLOBAL
, &Globals
.max_ttl
, NULL
},
493 {"dns proxy", P_BOOL
, P_GLOBAL
, &Globals
.bDNSproxy
, NULL
},
494 {"wins support", P_BOOL
, P_GLOBAL
, &Globals
.bWINSsupport
, NULL
},
495 {"wins proxy", P_BOOL
, P_GLOBAL
, &Globals
.bWINSproxy
, NULL
},
496 {"wins server", P_STRING
, P_GLOBAL
, &Globals
.szWINSserver
, NULL
},
497 {"preferred master", P_BOOL
, P_GLOBAL
, &Globals
.bPreferredMaster
, NULL
},
498 {"prefered master", P_BOOL
, P_GLOBAL
, &Globals
.bPreferredMaster
, NULL
},
499 {"local master", P_BOOL
, P_GLOBAL
, &Globals
.bLocalMaster
, NULL
},
500 {"domain master", P_BOOL
, P_GLOBAL
, &Globals
.bDomainMaster
, NULL
},
501 {"domain logons", P_BOOL
, P_GLOBAL
, &Globals
.bDomainLogons
, NULL
},
502 {"browse list", P_BOOL
, P_GLOBAL
, &Globals
.bBrowseList
, NULL
},
503 {"unix realname", P_BOOL
, P_GLOBAL
, &Globals
.bUnixRealname
, NULL
},
504 {"NIS homedir", P_BOOL
, P_GLOBAL
, &Globals
.bNISHomeMap
, NULL
},
505 {"time server", P_BOOL
, P_GLOBAL
, &Globals
.bTimeServer
, NULL
},
506 {"printer driver file", P_STRING
, P_GLOBAL
, &Globals
.szDriverFile
, NULL
},
507 {"-valid", P_BOOL
, P_LOCAL
, &sDefault
.valid
, NULL
},
508 {"comment", P_STRING
, P_LOCAL
, &sDefault
.comment
, NULL
},
509 {"copy", P_STRING
, P_LOCAL
, &sDefault
.szCopy
, handle_copy
},
510 {"include", P_STRING
, P_LOCAL
, &sDefault
.szInclude
, handle_include
},
511 {"exec", P_STRING
, P_LOCAL
, &sDefault
.szPreExec
, NULL
},
512 {"preexec", P_STRING
, P_LOCAL
, &sDefault
.szPreExec
, NULL
},
513 {"postexec", P_STRING
, P_LOCAL
, &sDefault
.szPostExec
, NULL
},
514 {"root preexec", P_STRING
, P_LOCAL
, &sDefault
.szRootPreExec
, NULL
},
515 {"root postexec", P_STRING
, P_LOCAL
, &sDefault
.szRootPostExec
, NULL
},
516 {"alternate permissions",P_BOOL
,P_LOCAL
, &sDefault
.bAlternatePerm
, NULL
},
517 {"revalidate", P_BOOL
, P_LOCAL
, &sDefault
.bRevalidate
, NULL
},
518 {"default case", P_INTEGER
, P_LOCAL
, &sDefault
.iDefaultCase
, handle_case
},
519 {"case sensitive", P_BOOL
, P_LOCAL
, &sDefault
.bCaseSensitive
, NULL
},
520 {"casesignames", P_BOOL
, P_LOCAL
, &sDefault
.bCaseSensitive
, NULL
},
521 {"preserve case", P_BOOL
, P_LOCAL
, &sDefault
.bCasePreserve
, NULL
},
522 {"short preserve case",P_BOOL
, P_LOCAL
, &sDefault
.bShortCasePreserve
,NULL
},
523 {"mangle case", P_BOOL
, P_LOCAL
, &sDefault
.bCaseMangle
, NULL
},
524 {"mangling char", P_CHAR
, P_LOCAL
, &sDefault
.magic_char
, NULL
},
525 {"browseable", P_BOOL
, P_LOCAL
, &sDefault
.bBrowseable
, NULL
},
526 {"browsable", P_BOOL
, P_LOCAL
, &sDefault
.bBrowseable
, NULL
},
527 {"available", P_BOOL
, P_LOCAL
, &sDefault
.bAvailable
, NULL
},
528 {"path", P_STRING
, P_LOCAL
, &sDefault
.szPath
, NULL
},
529 {"directory", P_STRING
, P_LOCAL
, &sDefault
.szPath
, NULL
},
530 {"username", P_STRING
, P_LOCAL
, &sDefault
.szUsername
, NULL
},
531 {"user", P_STRING
, P_LOCAL
, &sDefault
.szUsername
, NULL
},
532 {"users", P_STRING
, P_LOCAL
, &sDefault
.szUsername
, NULL
},
533 {"guest account", P_STRING
, P_LOCAL
, &sDefault
.szGuestaccount
, NULL
},
534 {"invalid users", P_STRING
, P_LOCAL
, &sDefault
.szInvalidUsers
, NULL
},
535 {"valid users", P_STRING
, P_LOCAL
, &sDefault
.szValidUsers
, NULL
},
536 {"admin users", P_STRING
, P_LOCAL
, &sDefault
.szAdminUsers
, NULL
},
537 {"read list", P_STRING
, P_LOCAL
, &sDefault
.readlist
, NULL
},
538 {"write list", P_STRING
, P_LOCAL
, &sDefault
.writelist
, NULL
},
539 {"volume", P_STRING
, P_LOCAL
, &sDefault
.volume
, NULL
},
540 {"force user", P_STRING
, P_LOCAL
, &sDefault
.force_user
, NULL
},
541 {"force group", P_STRING
, P_LOCAL
, &sDefault
.force_group
, NULL
},
542 {"group", P_STRING
, P_LOCAL
, &sDefault
.force_group
, NULL
},
543 {"read only", P_BOOL
, P_LOCAL
, &sDefault
.bRead_only
, NULL
},
544 {"write ok", P_BOOLREV
, P_LOCAL
, &sDefault
.bRead_only
, NULL
},
545 {"writeable", P_BOOLREV
, P_LOCAL
, &sDefault
.bRead_only
, NULL
},
546 {"writable", P_BOOLREV
, P_LOCAL
, &sDefault
.bRead_only
, NULL
},
547 {"max connections", P_INTEGER
, P_LOCAL
, &sDefault
.iMaxConnections
, NULL
},
548 {"min print space", P_INTEGER
, P_LOCAL
, &sDefault
.iMinPrintSpace
, NULL
},
549 {"create mask", P_OCTAL
, P_LOCAL
, &sDefault
.iCreate_mask
, NULL
},
550 {"create mode", P_OCTAL
, P_LOCAL
, &sDefault
.iCreate_mask
, NULL
},
551 {"force create mode",P_OCTAL
, P_LOCAL
, &sDefault
.iCreate_force_mode
, NULL
},
552 {"directory mask", P_OCTAL
, P_LOCAL
, &sDefault
.iDir_mask
, NULL
},
553 {"directory mode", P_OCTAL
, P_LOCAL
, &sDefault
.iDir_mask
, NULL
},
554 {"force directory mode", P_OCTAL
, P_LOCAL
, &sDefault
.iDir_force_mode
, NULL
},
555 {"set directory", P_BOOLREV
, P_LOCAL
, &sDefault
.bNo_set_dir
, NULL
},
556 {"status", P_BOOL
, P_LOCAL
, &sDefault
.status
, NULL
},
557 {"hide dot files", P_BOOL
, P_LOCAL
, &sDefault
.bHideDotFiles
, NULL
},
558 {"delete veto files",P_BOOL
, P_LOCAL
, &sDefault
.bDeleteVetoFiles
, NULL
},
559 {"veto files", P_STRING
, P_LOCAL
, &sDefault
.szVetoFiles
, NULL
},
560 {"hide files", P_STRING
, P_LOCAL
, &sDefault
.szHideFiles
, NULL
},
561 {"veto oplock files",P_STRING
, P_LOCAL
, &sDefault
.szVetoOplockFiles
,NULL
},
562 {"guest only", P_BOOL
, P_LOCAL
, &sDefault
.bGuest_only
, NULL
},
563 {"only guest", P_BOOL
, P_LOCAL
, &sDefault
.bGuest_only
, NULL
},
564 {"guest ok", P_BOOL
, P_LOCAL
, &sDefault
.bGuest_ok
, NULL
},
565 {"public", P_BOOL
, P_LOCAL
, &sDefault
.bGuest_ok
, NULL
},
566 {"print ok", P_BOOL
, P_LOCAL
, &sDefault
.bPrint_ok
, NULL
},
567 {"printable", P_BOOL
, P_LOCAL
, &sDefault
.bPrint_ok
, NULL
},
568 {"postscript", P_BOOL
, P_LOCAL
, &sDefault
.bPostscript
, NULL
},
569 {"map system", P_BOOL
, P_LOCAL
, &sDefault
.bMap_system
, NULL
},
570 {"map hidden", P_BOOL
, P_LOCAL
, &sDefault
.bMap_hidden
, NULL
},
571 {"map archive", P_BOOL
, P_LOCAL
, &sDefault
.bMap_archive
, NULL
},
572 {"locking", P_BOOL
, P_LOCAL
, &sDefault
.bLocking
, NULL
},
573 {"strict locking", P_BOOL
, P_LOCAL
, &sDefault
.bStrictLocking
, NULL
},
574 {"share modes", P_BOOL
, P_LOCAL
, &sDefault
.bShareModes
, NULL
},
575 {"oplocks", P_BOOL
, P_LOCAL
, &sDefault
.bOpLocks
, NULL
},
576 {"only user", P_BOOL
, P_LOCAL
, &sDefault
.bOnlyUser
, NULL
},
577 {"wide links", P_BOOL
, P_LOCAL
, &sDefault
.bWidelinks
, NULL
},
578 {"follow symlinks", P_BOOL
, P_LOCAL
, &sDefault
.bSymlinks
, NULL
},
579 {"sync always", P_BOOL
, P_LOCAL
, &sDefault
.bSyncAlways
, NULL
},
580 {"mangled names", P_BOOL
, P_LOCAL
, &sDefault
.bMangledNames
, NULL
},
581 {"fake oplocks", P_BOOL
, P_LOCAL
, &sDefault
.bFakeOplocks
, NULL
},
582 {"print command", P_STRING
, P_LOCAL
, &sDefault
.szPrintcommand
, NULL
},
583 {"lpq command", P_STRING
, P_LOCAL
, &sDefault
.szLpqcommand
, NULL
},
584 {"lprm command", P_STRING
, P_LOCAL
, &sDefault
.szLprmcommand
, NULL
},
585 {"lppause command", P_STRING
, P_LOCAL
, &sDefault
.szLppausecommand
, NULL
},
586 {"lpresume command", P_STRING
, P_LOCAL
, &sDefault
.szLpresumecommand
,NULL
},
587 {"printer", P_STRING
, P_LOCAL
, &sDefault
.szPrintername
, NULL
},
588 {"printer name", P_STRING
, P_LOCAL
, &sDefault
.szPrintername
, NULL
},
589 {"printer driver", P_STRING
, P_LOCAL
, &sDefault
.szPrinterDriver
, NULL
},
590 {"printer driver location", P_STRING
, P_LOCAL
, &sDefault
.szPrinterDriverLocation
, NULL
},
591 {"hosts allow", P_STRING
, P_LOCAL
, &sDefault
.szHostsallow
, NULL
},
592 {"allow hosts", P_STRING
, P_LOCAL
, &sDefault
.szHostsallow
, NULL
},
593 {"hosts deny", P_STRING
, P_LOCAL
, &sDefault
.szHostsdeny
, NULL
},
594 {"deny hosts", P_STRING
, P_LOCAL
, &sDefault
.szHostsdeny
, NULL
},
595 {"dont descend", P_STRING
, P_LOCAL
, &sDefault
.szDontdescend
, NULL
},
596 {"magic script", P_STRING
, P_LOCAL
, &sDefault
.szMagicScript
, NULL
},
597 {"magic output", P_STRING
, P_LOCAL
, &sDefault
.szMagicOutput
, NULL
},
598 {"mangled map", P_STRING
, P_LOCAL
, &sDefault
.szMangledMap
, NULL
},
599 {"delete readonly", P_BOOL
, P_LOCAL
, &sDefault
.bDeleteReadonly
, NULL
},
600 {"dos filetimes", P_BOOL
, P_LOCAL
, &sDefault
.bDosFiletimes
, NULL
},
602 {NULL
, P_BOOL
, P_NONE
, NULL
, NULL
}
607 /***************************************************************************
608 Initialise the global parameter structure.
609 ***************************************************************************/
610 static void init_globals(void)
612 static BOOL done_init
= False
;
618 bzero((void *)&Globals
,sizeof(Globals
));
620 for (i
= 0; parm_table
[i
].label
; i
++)
621 if ((parm_table
[i
].type
== P_STRING
||
622 parm_table
[i
].type
== P_USTRING
) &&
624 string_init(parm_table
[i
].ptr
,"");
626 string_set(&sDefault
.szGuestaccount
, GUEST_ACCOUNT
);
627 string_set(&sDefault
.szPrinterDriver
, "NULL");
633 DEBUG(3,("Initialising global parameters\n"));
635 #ifdef SMB_PASSWD_FILE
636 string_set(&Globals
.szSMBPasswdFile
, SMB_PASSWD_FILE
);
638 string_set(&Globals
.szPasswdChat
,"*old*password* %o\\n *new*password* %n\\n *new*password* %n\\n *changed*");
639 string_set(&Globals
.szWorkGroup
, WORKGROUP
);
640 string_set(&Globals
.szPasswdProgram
, SMB_PASSWD
);
641 string_set(&Globals
.szPrintcapname
, PRINTCAP_NAME
);
642 string_set(&Globals
.szDriverFile
, DRIVERFILE
);
643 string_set(&Globals
.szLockDir
, LOCKDIR
);
644 string_set(&Globals
.szRootdir
, "/");
645 string_set(&Globals
.szSmbrun
, SMBRUN
);
646 string_set(&Globals
.szSocketAddress
, "0.0.0.0");
647 sprintf(s
,"Samba %s",VERSION
);
648 string_set(&Globals
.szServerString
,s
);
649 sprintf(s
,"%d.%d", DEFAULT_MAJOR_VERSION
, DEFAULT_MINOR_VERSION
);
650 string_set(&Globals
.szAnnounceVersion
,s
);
652 string_set(&Globals
.szLogonDrive
, "");
653 /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
654 string_set(&Globals
.szLogonHome
, "\\\\%N\\%U");
655 string_set(&Globals
.szLogonPath
, "\\\\%N\\%U\\profile");
657 Globals
.bLoadPrinters
= True
;
658 Globals
.bUseRhosts
= False
;
659 Globals
.max_packet
= 65535;
660 Globals
.mangled_stack
= 50;
661 Globals
.max_xmit
= 65535;
662 Globals
.max_mux
= 50; /* This is *needed* for profile support. */
663 Globals
.lpqcachetime
= 10;
664 Globals
.pwordlevel
= 0;
665 Globals
.unamelevel
= 0;
666 Globals
.deadtime
= 0;
667 Globals
.max_log_size
= 5000;
668 Globals
.maxprotocol
= PROTOCOL_NT1
;
669 Globals
.security
= SEC_SHARE
;
670 Globals
.bEncryptPasswords
= False
;
671 Globals
.printing
= DEFAULT_PRINTING
;
672 Globals
.bReadRaw
= True
;
673 Globals
.bWriteRaw
= True
;
674 Globals
.bReadPrediction
= False
;
675 Globals
.bReadbmpx
= True
;
676 Globals
.bNullPasswords
= False
;
677 Globals
.bStripDot
= False
;
679 Globals
.bSyslogOnly
= False
;
680 Globals
.os_level
= 0;
681 Globals
.max_ttl
= 60*60*4; /* 2 hours default */
682 Globals
.ReadSize
= 16*1024;
683 Globals
.shmem_size
= SHMEM_SIZE
;
684 Globals
.announce_as
= ANNOUNCE_AS_NT
;
685 Globals
.bUnixRealname
= False
;
686 #if (defined(NETGROUP) && defined(AUTOMOUNT))
687 Globals
.bNISHomeMap
= False
;
688 string_set(&Globals
.szNISHomeMapName
, "auto.home");
690 coding_system
= interpret_coding_system (KANJI
, SJIS_CODE
);
691 Globals
.client_code_page
= DEFAULT_CLIENT_CODE_PAGE
;
692 Globals
.bTimeServer
= False
;
693 Globals
.bBindInterfacesOnly
= False
;
695 /* these parameters are set to defaults that are more appropriate
696 for the increasing samba install base:
698 as a member of the workgroup, that will possibly become a
699 _local_ master browser (lm = True). this is opposed to a forced
700 local master browser startup (pm = True).
702 doesn't provide WINS server service by default (wsupp = False),
703 and doesn't provide domain master browser services by default, either.
707 Globals
.bPreferredMaster
= False
;
708 Globals
.bLocalMaster
= True
;
709 Globals
.bDomainMaster
= False
;
710 Globals
.bDomainLogons
= False
;
711 Globals
.bBrowseList
= True
;
712 Globals
.bWINSsupport
= False
;
713 Globals
.bWINSproxy
= False
;
715 /* this parameter is currently set to the default functionality
716 in samba. given that w95 and NT is starting to use DNS for
717 server resolution, i expect that at some point it would be
718 sensible to default this to False.
720 this parameter is added because nmbd is a single process, and
721 gethostbyname is a blocking call, which can take out nmbd for
722 several seconds while a dns lookup is performed.
726 Globals
.bDNSproxy
= True
;
729 /***************************************************************************
730 check if a string is initialised and if not then initialise it
731 ***************************************************************************/
732 static void string_initial(char **s
,char *v
)
739 /***************************************************************************
740 Initialise the sDefault parameter structure.
741 ***************************************************************************/
742 static void init_locals(void)
744 /* choose defaults depending on the type of printing */
745 switch (Globals
.printing
)
751 string_initial(&sDefault
.szLpqcommand
,"lpq -P%p");
752 string_initial(&sDefault
.szLprmcommand
,"lprm -P%p %j");
753 string_initial(&sDefault
.szPrintcommand
,"lpr -r -P%p %s");
758 string_initial(&sDefault
.szLpqcommand
,"lpstat -o%p");
759 string_initial(&sDefault
.szLprmcommand
,"cancel %p-%j");
760 string_initial(&sDefault
.szPrintcommand
,"lp -c -d%p %s; rm %s");
762 string_initial(&sDefault
.szLppausecommand
,"lp -i %p-%j -H hold");
763 string_initial(&sDefault
.szLpresumecommand
,"lp -i %p-%j -H resume");
768 string_initial(&sDefault
.szLpqcommand
,"lpq -P%p");
769 string_initial(&sDefault
.szLprmcommand
,"lprm -P%p %j");
770 string_initial(&sDefault
.szPrintcommand
,"lp -r -P%p %s");
778 /******************************************************************* a
779 convenience routine to grab string parameters into a rotating buffer,
780 and run standard_sub_basic on them. The buffers can be written to by
781 callers without affecting the source string.
782 ********************************************************************/
783 char *lp_string(char *s
)
785 static char *bufs
[10];
786 static int buflen
[10];
787 static int next
= -1;
790 int len
= s
?strlen(s
):0;
801 len
= MAX(len
+100,sizeof(pstring
)); /* the +100 is for some
804 if (buflen
[next
] != len
) {
806 if (bufs
[next
]) free(bufs
[next
]);
807 bufs
[next
] = (char *)malloc(len
);
809 DEBUG(0,("out of memory in lp_string()"));
814 ret
= &bufs
[next
][0];
822 trim_string(ret
, "\"", "\"");
824 standard_sub_basic(ret
);
830 In this section all the functions that are used to access the
831 parameters from the rest of the program are defined
834 #define FN_GLOBAL_STRING(fn_name,ptr) \
835 char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
836 #define FN_GLOBAL_BOOL(fn_name,ptr) \
837 BOOL fn_name(void) {return(*(BOOL *)(ptr));}
838 #define FN_GLOBAL_CHAR(fn_name,ptr) \
839 char fn_name(void) {return(*(char *)(ptr));}
840 #define FN_GLOBAL_INTEGER(fn_name,ptr) \
841 int fn_name(void) {return(*(int *)(ptr));}
843 #define FN_LOCAL_STRING(fn_name,val) \
844 char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i)&&pSERVICE(i)->val)?pSERVICE(i)->val : sDefault.val));}
845 #define FN_LOCAL_BOOL(fn_name,val) \
846 BOOL fn_name(int i) {return(LP_SNUM_OK(i)? pSERVICE(i)->val : sDefault.val);}
847 #define FN_LOCAL_CHAR(fn_name,val) \
848 char fn_name(int i) {return(LP_SNUM_OK(i)? pSERVICE(i)->val : sDefault.val);}
849 #define FN_LOCAL_INTEGER(fn_name,val) \
850 int fn_name(int i) {return(LP_SNUM_OK(i)? pSERVICE(i)->val : sDefault.val);}
852 FN_GLOBAL_STRING(lp_logfile
,&Globals
.szLogFile
)
853 FN_GLOBAL_STRING(lp_smbrun
,&Globals
.szSmbrun
)
854 FN_GLOBAL_STRING(lp_configfile
,&Globals
.szConfigFile
)
855 FN_GLOBAL_STRING(lp_smb_passwd_file
,&Globals
.szSMBPasswdFile
)
856 FN_GLOBAL_STRING(lp_serverstring
,&Globals
.szServerString
)
857 FN_GLOBAL_STRING(lp_printcapname
,&Globals
.szPrintcapname
)
858 FN_GLOBAL_STRING(lp_lockdir
,&Globals
.szLockDir
)
859 FN_GLOBAL_STRING(lp_rootdir
,&Globals
.szRootdir
)
860 FN_GLOBAL_STRING(lp_defaultservice
,&Globals
.szDefaultService
)
861 FN_GLOBAL_STRING(lp_msg_command
,&Globals
.szMsgCommand
)
862 FN_GLOBAL_STRING(lp_dfree_command
,&Globals
.szDfree
)
863 FN_GLOBAL_STRING(lp_hosts_equiv
,&Globals
.szHostsEquiv
)
864 FN_GLOBAL_STRING(lp_auto_services
,&Globals
.szAutoServices
)
865 FN_GLOBAL_STRING(lp_passwd_program
,&Globals
.szPasswdProgram
)
866 FN_GLOBAL_STRING(lp_passwd_chat
,&Globals
.szPasswdChat
)
867 FN_GLOBAL_STRING(lp_passwordserver
,&Globals
.szPasswordServer
)
868 FN_GLOBAL_STRING(lp_workgroup
,&Globals
.szWorkGroup
)
869 FN_GLOBAL_STRING(lp_username_map
,&Globals
.szUsernameMap
)
870 FN_GLOBAL_STRING(lp_character_set
,&Globals
.szCharacterSet
)
871 FN_GLOBAL_STRING(lp_logon_script
,&Globals
.szLogonScript
)
872 FN_GLOBAL_STRING(lp_logon_path
,&Globals
.szLogonPath
)
873 FN_GLOBAL_STRING(lp_logon_drive
,&Globals
.szLogonDrive
)
874 FN_GLOBAL_STRING(lp_logon_home
,&Globals
.szLogonHome
)
875 FN_GLOBAL_STRING(lp_remote_announce
,&Globals
.szRemoteAnnounce
)
876 FN_GLOBAL_STRING(lp_wins_server
,&Globals
.szWINSserver
)
877 FN_GLOBAL_STRING(lp_interfaces
,&Globals
.szInterfaces
)
878 FN_GLOBAL_STRING(lp_socket_address
,&Globals
.szSocketAddress
)
879 FN_GLOBAL_STRING(lp_nis_home_map_name
,&Globals
.szNISHomeMapName
)
880 FN_GLOBAL_STRING(lp_announce_version
,&Globals
.szAnnounceVersion
)
881 FN_GLOBAL_STRING(lp_netbios_aliases
,&Globals
.szNetbiosAliases
)
882 FN_GLOBAL_STRING(lp_driverfile
,&Globals
.szDriverFile
)
884 FN_GLOBAL_STRING(lp_domain_sid
,&Globals
.szDomainSID
)
885 FN_GLOBAL_STRING(lp_domain_other_sids
,&Globals
.szDomainOtherSIDs
)
886 FN_GLOBAL_STRING(lp_domain_groups
,&Globals
.szDomainGroups
)
887 FN_GLOBAL_STRING(lp_domain_admin_users
,&Globals
.szDomainAdminUsers
)
888 FN_GLOBAL_STRING(lp_domain_guest_users
,&Globals
.szDomainGuestUsers
)
889 FN_GLOBAL_STRING(lp_domain_hostsallow
,&Globals
.szDomainHostsallow
)
890 FN_GLOBAL_STRING(lp_domain_hostsdeny
,&Globals
.szDomainHostsdeny
)
893 FN_GLOBAL_BOOL(lp_dns_proxy
,&Globals
.bDNSproxy
)
894 FN_GLOBAL_BOOL(lp_wins_support
,&Globals
.bWINSsupport
)
895 FN_GLOBAL_BOOL(lp_wins_proxy
,&Globals
.bWINSproxy
)
896 FN_GLOBAL_BOOL(lp_local_master
,&Globals
.bLocalMaster
)
897 FN_GLOBAL_BOOL(lp_domain_controller
,&Globals
.bDomainController
)
898 FN_GLOBAL_BOOL(lp_domain_master
,&Globals
.bDomainMaster
)
899 FN_GLOBAL_BOOL(lp_domain_logons
,&Globals
.bDomainLogons
)
900 FN_GLOBAL_BOOL(lp_preferred_master
,&Globals
.bPreferredMaster
)
901 FN_GLOBAL_BOOL(lp_load_printers
,&Globals
.bLoadPrinters
)
902 FN_GLOBAL_BOOL(lp_use_rhosts
,&Globals
.bUseRhosts
)
903 FN_GLOBAL_BOOL(lp_getwdcache
,&use_getwd_cache
)
904 FN_GLOBAL_BOOL(lp_readprediction
,&Globals
.bReadPrediction
)
905 FN_GLOBAL_BOOL(lp_readbmpx
,&Globals
.bReadbmpx
)
906 FN_GLOBAL_BOOL(lp_readraw
,&Globals
.bReadRaw
)
907 FN_GLOBAL_BOOL(lp_writeraw
,&Globals
.bWriteRaw
)
908 FN_GLOBAL_BOOL(lp_null_passwords
,&Globals
.bNullPasswords
)
909 FN_GLOBAL_BOOL(lp_strip_dot
,&Globals
.bStripDot
)
910 FN_GLOBAL_BOOL(lp_encrypted_passwords
,&Globals
.bEncryptPasswords
)
911 FN_GLOBAL_BOOL(lp_syslog_only
,&Globals
.bSyslogOnly
)
912 FN_GLOBAL_BOOL(lp_browse_list
,&Globals
.bBrowseList
)
913 FN_GLOBAL_BOOL(lp_unix_realname
,&Globals
.bUnixRealname
)
914 FN_GLOBAL_BOOL(lp_nis_home_map
,&Globals
.bNISHomeMap
)
915 FN_GLOBAL_BOOL(lp_time_server
,&Globals
.bTimeServer
)
916 FN_GLOBAL_BOOL(lp_bind_interfaces_only
,&Globals
.bBindInterfacesOnly
)
918 FN_GLOBAL_INTEGER(lp_os_level
,&Globals
.os_level
)
919 FN_GLOBAL_INTEGER(lp_max_ttl
,&Globals
.max_ttl
)
920 FN_GLOBAL_INTEGER(lp_max_log_size
,&Globals
.max_log_size
)
921 FN_GLOBAL_INTEGER(lp_mangledstack
,&Globals
.mangled_stack
)
922 FN_GLOBAL_INTEGER(lp_maxxmit
,&Globals
.max_xmit
)
923 FN_GLOBAL_INTEGER(lp_maxmux
,&Globals
.max_mux
)
924 FN_GLOBAL_INTEGER(lp_maxpacket
,&Globals
.max_packet
)
925 FN_GLOBAL_INTEGER(lp_keepalive
,&keepalive
)
926 FN_GLOBAL_INTEGER(lp_passwordlevel
,&Globals
.pwordlevel
)
927 FN_GLOBAL_INTEGER(lp_usernamelevel
,&Globals
.unamelevel
)
928 FN_GLOBAL_INTEGER(lp_readsize
,&Globals
.ReadSize
)
929 FN_GLOBAL_INTEGER(lp_shmem_size
,&Globals
.shmem_size
)
930 FN_GLOBAL_INTEGER(lp_deadtime
,&Globals
.deadtime
)
931 FN_GLOBAL_INTEGER(lp_maxprotocol
,&Globals
.maxprotocol
)
932 FN_GLOBAL_INTEGER(lp_security
,&Globals
.security
)
933 FN_GLOBAL_INTEGER(lp_printing
,&Globals
.printing
)
934 FN_GLOBAL_INTEGER(lp_maxdisksize
,&Globals
.maxdisksize
)
935 FN_GLOBAL_INTEGER(lp_lpqcachetime
,&Globals
.lpqcachetime
)
936 FN_GLOBAL_INTEGER(lp_syslog
,&Globals
.syslog
)
937 FN_GLOBAL_INTEGER(lp_client_code_page
,&Globals
.client_code_page
)
938 FN_GLOBAL_INTEGER(lp_announce_as
,&Globals
.announce_as
)
940 FN_LOCAL_STRING(lp_preexec
,szPreExec
)
941 FN_LOCAL_STRING(lp_postexec
,szPostExec
)
942 FN_LOCAL_STRING(lp_rootpreexec
,szRootPreExec
)
943 FN_LOCAL_STRING(lp_rootpostexec
,szRootPostExec
)
944 FN_LOCAL_STRING(lp_servicename
,szService
)
945 FN_LOCAL_STRING(lp_pathname
,szPath
)
946 FN_LOCAL_STRING(lp_dontdescend
,szDontdescend
)
947 FN_LOCAL_STRING(lp_username
,szUsername
)
948 FN_LOCAL_STRING(lp_guestaccount
,szGuestaccount
)
949 FN_LOCAL_STRING(lp_invalid_users
,szInvalidUsers
)
950 FN_LOCAL_STRING(lp_valid_users
,szValidUsers
)
951 FN_LOCAL_STRING(lp_admin_users
,szAdminUsers
)
952 FN_LOCAL_STRING(lp_printcommand
,szPrintcommand
)
953 FN_LOCAL_STRING(lp_lpqcommand
,szLpqcommand
)
954 FN_LOCAL_STRING(lp_lprmcommand
,szLprmcommand
)
955 FN_LOCAL_STRING(lp_lppausecommand
,szLppausecommand
)
956 FN_LOCAL_STRING(lp_lpresumecommand
,szLpresumecommand
)
957 FN_LOCAL_STRING(lp_printername
,szPrintername
)
958 FN_LOCAL_STRING(lp_printerdriver
,szPrinterDriver
)
959 FN_LOCAL_STRING(lp_hostsallow
,szHostsallow
)
960 FN_LOCAL_STRING(lp_hostsdeny
,szHostsdeny
)
961 FN_LOCAL_STRING(lp_magicscript
,szMagicScript
)
962 FN_LOCAL_STRING(lp_magicoutput
,szMagicOutput
)
963 FN_LOCAL_STRING(lp_comment
,comment
)
964 FN_LOCAL_STRING(lp_force_user
,force_user
)
965 FN_LOCAL_STRING(lp_force_group
,force_group
)
966 FN_LOCAL_STRING(lp_readlist
,readlist
)
967 FN_LOCAL_STRING(lp_writelist
,writelist
)
968 FN_LOCAL_STRING(lp_volume
,volume
)
969 FN_LOCAL_STRING(lp_mangled_map
,szMangledMap
)
970 FN_LOCAL_STRING(lp_veto_files
,szVetoFiles
)
971 FN_LOCAL_STRING(lp_hide_files
,szHideFiles
)
972 FN_LOCAL_STRING(lp_veto_oplocks
,szVetoFiles
)
973 FN_LOCAL_STRING(lp_driverlocation
,szPrinterDriverLocation
)
975 FN_LOCAL_BOOL(lp_alternate_permissions
,bAlternatePerm
)
976 FN_LOCAL_BOOL(lp_revalidate
,bRevalidate
)
977 FN_LOCAL_BOOL(lp_casesensitive
,bCaseSensitive
)
978 FN_LOCAL_BOOL(lp_preservecase
,bCasePreserve
)
979 FN_LOCAL_BOOL(lp_shortpreservecase
,bShortCasePreserve
)
980 FN_LOCAL_BOOL(lp_casemangle
,bCaseMangle
)
981 FN_LOCAL_BOOL(lp_status
,status
)
982 FN_LOCAL_BOOL(lp_hide_dot_files
,bHideDotFiles
)
983 FN_LOCAL_BOOL(lp_browseable
,bBrowseable
)
984 FN_LOCAL_BOOL(lp_readonly
,bRead_only
)
985 FN_LOCAL_BOOL(lp_no_set_dir
,bNo_set_dir
)
986 FN_LOCAL_BOOL(lp_guest_ok
,bGuest_ok
)
987 FN_LOCAL_BOOL(lp_guest_only
,bGuest_only
)
988 FN_LOCAL_BOOL(lp_print_ok
,bPrint_ok
)
989 FN_LOCAL_BOOL(lp_postscript
,bPostscript
)
990 FN_LOCAL_BOOL(lp_map_hidden
,bMap_hidden
)
991 FN_LOCAL_BOOL(lp_map_archive
,bMap_archive
)
992 FN_LOCAL_BOOL(lp_locking
,bLocking
)
993 FN_LOCAL_BOOL(lp_strict_locking
,bStrictLocking
)
994 FN_LOCAL_BOOL(lp_share_modes
,bShareModes
)
995 FN_LOCAL_BOOL(lp_oplocks
,bOpLocks
)
996 FN_LOCAL_BOOL(lp_onlyuser
,bOnlyUser
)
997 FN_LOCAL_BOOL(lp_manglednames
,bMangledNames
)
998 FN_LOCAL_BOOL(lp_widelinks
,bWidelinks
)
999 FN_LOCAL_BOOL(lp_symlinks
,bSymlinks
)
1000 FN_LOCAL_BOOL(lp_syncalways
,bSyncAlways
)
1001 FN_LOCAL_BOOL(lp_map_system
,bMap_system
)
1002 FN_LOCAL_BOOL(lp_delete_readonly
,bDeleteReadonly
)
1003 FN_LOCAL_BOOL(lp_fake_oplocks
,bFakeOplocks
)
1004 FN_LOCAL_BOOL(lp_recursive_veto_delete
,bDeleteVetoFiles
)
1005 FN_LOCAL_BOOL(lp_dos_filetimes
,bDosFiletimes
)
1007 FN_LOCAL_INTEGER(lp_create_mode
,iCreate_mask
)
1008 FN_LOCAL_INTEGER(lp_force_create_mode
,iCreate_force_mode
)
1009 FN_LOCAL_INTEGER(lp_dir_mode
,iDir_mask
)
1010 FN_LOCAL_INTEGER(lp_force_dir_mode
,iDir_force_mode
)
1011 FN_LOCAL_INTEGER(lp_max_connections
,iMaxConnections
)
1012 FN_LOCAL_INTEGER(lp_defaultcase
,iDefaultCase
)
1013 FN_LOCAL_INTEGER(lp_minprintspace
,iMinPrintSpace
)
1015 FN_LOCAL_CHAR(lp_magicchar
,magic_char
)
1019 /* local prototypes */
1020 static int strwicmp( char *psz1
, char *psz2
);
1021 static int map_parameter( char *pszParmName
);
1022 static BOOL
set_boolean( BOOL
*pb
, char *pszParmValue
);
1023 static int getservicebyname(char *pszServiceName
, service
*pserviceDest
);
1024 static void copy_service( service
*pserviceDest
,
1025 service
*pserviceSource
,
1026 BOOL
*pcopymapDest
);
1027 static BOOL
service_ok(int iService
);
1028 static BOOL
do_parameter(char *pszParmName
, char *pszParmValue
);
1029 static BOOL
do_section(char *pszSectionName
);
1030 static void init_copymap(service
*pservice
);
1033 /***************************************************************************
1034 initialise a service to the defaults
1035 ***************************************************************************/
1036 static void init_service(service
*pservice
)
1038 bzero((char *)pservice
,sizeof(service
));
1039 copy_service(pservice
,&sDefault
,NULL
);
1043 /***************************************************************************
1044 free the dynamically allocated parts of a service struct
1045 ***************************************************************************/
1046 static void free_service(service
*pservice
)
1052 for (i
=0;parm_table
[i
].label
;i
++)
1053 if ((parm_table
[i
].type
== P_STRING
||
1054 parm_table
[i
].type
== P_STRING
) &&
1055 parm_table
[i
].class == P_LOCAL
)
1056 string_free((char **)(((char *)pservice
) + PTR_DIFF(parm_table
[i
].ptr
,&sDefault
)));
1059 /***************************************************************************
1060 add a new service to the services array initialising it with the given
1062 ***************************************************************************/
1063 static int add_a_service(service
*pservice
, char *name
)
1067 int num_to_alloc
= iNumServices
+1;
1069 tservice
= *pservice
;
1071 /* it might already exist */
1074 i
= getservicebyname(name
,NULL
);
1079 /* find an invalid one */
1080 for (i
=0;i
<iNumServices
;i
++)
1081 if (!pSERVICE(i
)->valid
)
1084 /* if not, then create one */
1085 if (i
== iNumServices
)
1087 ServicePtrs
= (service
**)Realloc(ServicePtrs
,sizeof(service
*)*num_to_alloc
);
1089 pSERVICE(iNumServices
) = (service
*)malloc(sizeof(service
));
1091 if (!ServicePtrs
|| !pSERVICE(iNumServices
))
1097 free_service(pSERVICE(i
));
1099 pSERVICE(i
)->valid
= True
;
1101 init_service(pSERVICE(i
));
1102 copy_service(pSERVICE(i
),&tservice
,NULL
);
1104 string_set(&iSERVICE(i
).szService
,name
);
1109 /***************************************************************************
1110 add a new home service, with the specified home directory, defaults coming
1112 ***************************************************************************/
1113 BOOL
lp_add_home(char *pszHomename
, int iDefaultService
, char *pszHomedir
)
1115 int i
= add_a_service(pSERVICE(iDefaultService
),pszHomename
);
1120 if (!(*(iSERVICE(i
).szPath
)) || strequal(iSERVICE(i
).szPath
,lp_pathname(-1)))
1121 string_set(&iSERVICE(i
).szPath
,pszHomedir
);
1122 if (!(*(iSERVICE(i
).comment
)))
1125 sprintf(comment
,"Home directory of %s",pszHomename
);
1126 string_set(&iSERVICE(i
).comment
,comment
);
1128 iSERVICE(i
).bAvailable
= sDefault
.bAvailable
;
1129 iSERVICE(i
).bBrowseable
= sDefault
.bBrowseable
;
1131 DEBUG(3,("adding home directory %s at %s\n", pszHomename
, pszHomedir
));
1136 /***************************************************************************
1137 add a new service, based on an old one
1138 ***************************************************************************/
1139 int lp_add_service(char *pszService
, int iDefaultService
)
1141 return(add_a_service(pSERVICE(iDefaultService
),pszService
));
1145 /***************************************************************************
1147 ***************************************************************************/
1148 static BOOL
lp_add_ipc(void)
1151 int i
= add_a_service(&sDefault
,"IPC$");
1156 sprintf(comment
,"IPC Service (%s)",lp_serverstring());
1158 string_set(&iSERVICE(i
).szPath
,tmpdir());
1159 string_set(&iSERVICE(i
).szUsername
,"");
1160 string_set(&iSERVICE(i
).comment
,comment
);
1161 iSERVICE(i
).status
= False
;
1162 iSERVICE(i
).iMaxConnections
= 0;
1163 iSERVICE(i
).bAvailable
= True
;
1164 iSERVICE(i
).bRead_only
= True
;
1165 iSERVICE(i
).bGuest_only
= False
;
1166 iSERVICE(i
).bGuest_ok
= True
;
1167 iSERVICE(i
).bPrint_ok
= False
;
1168 iSERVICE(i
).bBrowseable
= sDefault
.bBrowseable
;
1170 DEBUG(3,("adding IPC service\n"));
1176 /***************************************************************************
1177 add a new printer service, with defaults coming from service iFrom
1178 ***************************************************************************/
1179 BOOL
lp_add_printer(char *pszPrintername
, int iDefaultService
)
1181 char *comment
= "From Printcap";
1182 int i
= add_a_service(pSERVICE(iDefaultService
),pszPrintername
);
1187 /* note that we do NOT default the availability flag to True - */
1188 /* we take it from the default service passed. This allows all */
1189 /* dynamic printers to be disabled by disabling the [printers] */
1190 /* entry (if/when the 'available' keyword is implemented!). */
1192 /* the printer name is set to the service name. */
1193 string_set(&iSERVICE(i
).szPrintername
,pszPrintername
);
1194 string_set(&iSERVICE(i
).comment
,comment
);
1195 iSERVICE(i
).bBrowseable
= sDefault
.bBrowseable
;
1196 /* Printers cannot be read_only. */
1197 iSERVICE(i
).bRead_only
= False
;
1198 /* No share modes on printer services. */
1199 iSERVICE(i
).bShareModes
= False
;
1200 /* No oplocks on printer services. */
1201 iSERVICE(i
).bOpLocks
= False
;
1202 /* Printer services must be printable. */
1203 iSERVICE(i
).bPrint_ok
= True
;
1205 DEBUG(3,("adding printer service %s\n",pszPrintername
));
1211 /***************************************************************************
1212 Do a case-insensitive, whitespace-ignoring string compare.
1213 ***************************************************************************/
1214 static int strwicmp(char *psz1
, char *psz2
)
1216 /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */
1217 /* appropriate value. */
1227 /* sync the strings on first non-whitespace */
1230 while (isspace(*psz1
))
1232 while (isspace(*psz2
))
1234 if (toupper(*psz1
) != toupper(*psz2
) || *psz1
== '\0' || *psz2
== '\0')
1239 return (*psz1
- *psz2
);
1242 /***************************************************************************
1243 Map a parameter's string representation to something we can use.
1244 Returns False if the parameter string is not recognised, else TRUE.
1245 ***************************************************************************/
1246 static int map_parameter(char *pszParmName
)
1250 if (*pszParmName
== '-')
1253 for (iIndex
= 0; parm_table
[iIndex
].label
; iIndex
++)
1254 if (strwicmp(parm_table
[iIndex
].label
, pszParmName
) == 0)
1257 DEBUG(0,( "Unknown parameter encountered: \"%s\"\n", pszParmName
));
1262 /***************************************************************************
1263 Set a boolean variable from the text value stored in the passed string.
1264 Returns True in success, False if the passed string does not correctly
1265 represent a boolean.
1266 ***************************************************************************/
1267 static BOOL
set_boolean(BOOL
*pb
, char *pszParmValue
)
1272 if (strwicmp(pszParmValue
, "yes") == 0 ||
1273 strwicmp(pszParmValue
, "true") == 0 ||
1274 strwicmp(pszParmValue
, "1") == 0)
1277 if (strwicmp(pszParmValue
, "no") == 0 ||
1278 strwicmp(pszParmValue
, "False") == 0 ||
1279 strwicmp(pszParmValue
, "0") == 0)
1283 DEBUG(0,( "Badly formed boolean in configuration file: \"%s\".\n",
1290 /***************************************************************************
1291 Find a service by name. Otherwise works like get_service.
1292 ***************************************************************************/
1293 static int getservicebyname(char *pszServiceName
, service
*pserviceDest
)
1297 for (iService
= iNumServices
- 1; iService
>= 0; iService
--)
1298 if (VALID(iService
) &&
1299 strwicmp(iSERVICE(iService
).szService
, pszServiceName
) == 0)
1301 if (pserviceDest
!= NULL
)
1302 copy_service(pserviceDest
, pSERVICE(iService
), NULL
);
1311 /***************************************************************************
1312 Copy a service structure to another
1314 If pcopymapDest is NULL then copy all fields
1315 ***************************************************************************/
1316 static void copy_service(service
*pserviceDest
,
1317 service
*pserviceSource
,
1321 BOOL bcopyall
= (pcopymapDest
== NULL
);
1323 for (i
=0;parm_table
[i
].label
;i
++)
1324 if (parm_table
[i
].ptr
&& parm_table
[i
].class == P_LOCAL
&&
1325 (bcopyall
|| pcopymapDest
[i
]))
1327 void *def_ptr
= parm_table
[i
].ptr
;
1329 ((char *)pserviceSource
) + PTR_DIFF(def_ptr
,&sDefault
);
1331 ((char *)pserviceDest
) + PTR_DIFF(def_ptr
,&sDefault
);
1333 switch (parm_table
[i
].type
)
1337 *(BOOL
*)dest_ptr
= *(BOOL
*)src_ptr
;
1342 *(int *)dest_ptr
= *(int *)src_ptr
;
1346 *(char *)dest_ptr
= *(char *)src_ptr
;
1350 string_set(dest_ptr
,*(char **)src_ptr
);
1354 string_set(dest_ptr
,*(char **)src_ptr
);
1355 strupper(*(char **)dest_ptr
);
1364 init_copymap(pserviceDest
);
1365 if (pserviceSource
->copymap
)
1366 memcpy((void *)pserviceDest
->copymap
,
1367 (void *)pserviceSource
->copymap
,sizeof(BOOL
)*NUMPARAMETERS
);
1371 /***************************************************************************
1372 Check a service for consistency. Return False if the service is in any way
1373 incomplete or faulty, else True.
1374 ***************************************************************************/
1375 static BOOL
service_ok(int iService
)
1380 if (iSERVICE(iService
).szService
[0] == '\0')
1382 DEBUG(0,( "The following message indicates an internal error:\n"));
1383 DEBUG(0,( "No service name in service entry.\n"));
1387 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
1388 /* I can't see why you'd want a non-printable printer service... */
1389 if (strwicmp(iSERVICE(iService
).szService
,PRINTERS_NAME
) == 0)
1390 if (!iSERVICE(iService
).bPrint_ok
)
1392 DEBUG(0,( "WARNING: [%s] service MUST be printable!\n",
1393 iSERVICE(iService
).szService
));
1394 iSERVICE(iService
).bPrint_ok
= True
;
1397 if (iSERVICE(iService
).szPath
[0] == '\0' &&
1398 strwicmp(iSERVICE(iService
).szService
,HOMES_NAME
) != 0)
1400 DEBUG(0,("No path in service %s - using %s\n",iSERVICE(iService
).szService
,tmpdir()));
1401 string_set(&iSERVICE(iService
).szPath
,tmpdir());
1404 /* If a service is flagged unavailable, log the fact at level 0. */
1405 if (!iSERVICE(iService
).bAvailable
)
1406 DEBUG(1,( "NOTE: Service %s is flagged unavailable.\n",
1407 iSERVICE(iService
).szService
));
1412 static struct file_lists
{
1413 struct file_lists
*next
;
1416 } *file_lists
= NULL
;
1418 /*******************************************************************
1419 keep a linked list of all config files so we know when one has changed
1420 it's date and needs to be reloaded
1421 ********************************************************************/
1422 static void add_to_file_list(char *fname
)
1424 struct file_lists
*f
=file_lists
;
1427 if (f
->name
&& !strcmp(f
->name
,fname
)) break;
1432 f
= (struct file_lists
*)malloc(sizeof(file_lists
[0]));
1434 f
->next
= file_lists
;
1435 f
->name
= strdup(fname
);
1446 standard_sub_basic(n2
);
1447 f
->modtime
= file_modtime(n2
);
1452 /*******************************************************************
1453 check if a config file has changed date
1454 ********************************************************************/
1455 BOOL
lp_file_list_changed(void)
1457 struct file_lists
*f
= file_lists
;
1458 DEBUG(6,("lp_file_list_changed()\n"));
1465 pstrcpy(n2
,f
->name
);
1466 standard_sub_basic(n2
);
1468 DEBUG(6,("file %s -> %s last mod_time: %s\n",
1469 f
->name
, n2
, ctime(&f
->modtime
)));
1471 mod_time
= file_modtime(n2
);
1473 if (f
->modtime
!= mod_time
) {
1474 DEBUG(6,("file %s modified: %s\n", n2
, ctime(&mod_time
)));
1475 f
->modtime
= mod_time
;
1483 /***************************************************************************
1484 handle the interpretation of the coding system parameter
1485 *************************************************************************/
1486 static BOOL
handle_coding_system(char *pszParmValue
,int *val
)
1488 *val
= interpret_coding_system(pszParmValue
,*val
);
1492 /***************************************************************************
1493 handle the interpretation of the character set system parameter
1494 ***************************************************************************/
1495 static BOOL
handle_character_set(char *pszParmValue
,int *val
)
1497 string_set(&Globals
.szCharacterSet
,pszParmValue
);
1498 *val
= interpret_character_set(pszParmValue
,*val
);
1503 /***************************************************************************
1504 handle the interpretation of the protocol parameter
1505 ***************************************************************************/
1506 static BOOL
handle_protocol(char *pszParmValue
,int *val
)
1508 *val
= interpret_protocol(pszParmValue
,*val
);
1512 /***************************************************************************
1513 handle the interpretation of the security parameter
1514 ***************************************************************************/
1515 static BOOL
handle_security(char *pszParmValue
,int *val
)
1517 *val
= interpret_security(pszParmValue
,*val
);
1521 /***************************************************************************
1522 handle the interpretation of the default case
1523 ***************************************************************************/
1524 static BOOL
handle_case(char *pszParmValue
,int *val
)
1526 if (strnequal(pszParmValue
,"LOWER", 5))
1528 else if (strnequal(pszParmValue
,"UPPER", 5))
1533 /***************************************************************************
1534 handle the interpretation of the printing system
1535 ***************************************************************************/
1536 static BOOL
handle_printing(char *pszParmValue
,int *val
)
1538 if (strnequal(pszParmValue
,"sysv", 4))
1540 else if (strnequal(pszParmValue
,"aix", 3))
1542 else if (strnequal(pszParmValue
,"hpux", 4))
1544 else if (strnequal(pszParmValue
,"bsd", 3))
1546 else if (strnequal(pszParmValue
,"qnx",3))
1548 else if (strnequal(pszParmValue
,"plp", 3))
1550 else if (strnequal(pszParmValue
,"lprng", 5))
1555 /***************************************************************************
1556 handle the announce as parameter
1557 ***************************************************************************/
1558 static BOOL
handle_announce_as(char *pszParmValue
,int *val
)
1560 if (strnequal(pszParmValue
,"NT", 2))
1561 *val
= ANNOUNCE_AS_NT
;
1562 else if (strnequal(pszParmValue
,"win95", 5))
1563 *val
= ANNOUNCE_AS_WIN95
;
1564 else if (strnequal(pszParmValue
,"WfW", 3))
1565 *val
= ANNOUNCE_AS_WFW
;
1569 /***************************************************************************
1570 handle the valid chars lines
1571 ***************************************************************************/
1572 static BOOL
handle_valid_chars(char *pszParmValue
,char **ptr
)
1574 string_set(ptr
,pszParmValue
);
1576 /* A dependency here is that the parameter client code page must be
1577 set before this is called - as calling codepage_initialise()
1578 would overwrite the valid char lines.
1580 codepage_initialise(lp_client_code_page());
1582 add_char_string(pszParmValue
);
1587 /***************************************************************************
1588 handle the include operation
1589 ***************************************************************************/
1590 static BOOL
handle_include(char *pszParmValue
,char **ptr
)
1593 pstrcpy(fname
,pszParmValue
);
1595 add_to_file_list(fname
);
1597 standard_sub_basic(fname
);
1599 string_set(ptr
,fname
);
1601 if (file_exist(fname
,NULL
))
1602 return(pm_process(fname
, do_section
, do_parameter
));
1604 DEBUG(2,("Can't find include file %s\n",fname
));
1610 /***************************************************************************
1611 handle the interpretation of the copy parameter
1612 ***************************************************************************/
1613 static BOOL
handle_copy(char *pszParmValue
,char **ptr
)
1617 service serviceTemp
;
1619 string_set(ptr
,pszParmValue
);
1621 init_service(&serviceTemp
);
1625 DEBUG(3,("Copying service from service %s\n",pszParmValue
));
1627 if ((iTemp
= getservicebyname(pszParmValue
, &serviceTemp
)) >= 0)
1629 if (iTemp
== iServiceIndex
)
1631 DEBUG(0,("Can't copy service %s - unable to copy self!\n",
1636 copy_service(pSERVICE(iServiceIndex
),
1638 iSERVICE(iServiceIndex
).copymap
);
1644 DEBUG(0,( "Unable to copy service - source not found: %s\n",
1649 free_service(&serviceTemp
);
1654 /***************************************************************************
1655 initialise a copymap
1656 ***************************************************************************/
1657 static void init_copymap(service
*pservice
)
1660 if (pservice
->copymap
) free(pservice
->copymap
);
1661 pservice
->copymap
= (BOOL
*)malloc(sizeof(BOOL
)*NUMPARAMETERS
);
1662 if (!pservice
->copymap
)
1663 DEBUG(0,("Couldn't allocate copymap!! (size %d)\n",NUMPARAMETERS
));
1665 for (i
=0;i
<NUMPARAMETERS
;i
++)
1666 pservice
->copymap
[i
] = True
;
1670 /***************************************************************************
1671 Process a parameter for a particular service number. If snum < 0
1672 then assume we are in the globals
1673 ***************************************************************************/
1674 BOOL
lp_do_parameter(int snum
, char *pszParmName
, char *pszParmValue
)
1677 void *parm_ptr
=NULL
; /* where we are going to store the result */
1680 parmnum
= map_parameter(pszParmName
);
1684 DEBUG(0,( "Ignoring unknown parameter \"%s\"\n", pszParmName
));
1688 def_ptr
= parm_table
[parmnum
].ptr
;
1690 /* we might point at a service, the default service or a global */
1694 if (parm_table
[parmnum
].class == P_GLOBAL
) {
1695 DEBUG(0,( "Global parameter %s found in service section!\n",pszParmName
));
1698 parm_ptr
= ((char *)pSERVICE(snum
)) + PTR_DIFF(def_ptr
,&sDefault
);
1703 if (!iSERVICE(snum
).copymap
)
1704 init_copymap(pSERVICE(snum
));
1706 /* this handles the aliases - set the copymap for other entries with
1707 the same data pointer */
1708 for (i
=0;parm_table
[i
].label
;i
++)
1709 if (parm_table
[i
].ptr
== parm_table
[parmnum
].ptr
)
1710 iSERVICE(snum
).copymap
[i
] = False
;
1713 /* if it is a special case then go ahead */
1714 if (parm_table
[parmnum
].special
) {
1715 parm_table
[parmnum
].special(pszParmValue
,parm_ptr
);
1719 /* now switch on the type of variable it is */
1720 switch (parm_table
[parmnum
].type
)
1723 set_boolean(parm_ptr
,pszParmValue
);
1727 set_boolean(parm_ptr
,pszParmValue
);
1728 *(BOOL
*)parm_ptr
= ! *(BOOL
*)parm_ptr
;
1732 *(int *)parm_ptr
= atoi(pszParmValue
);
1736 *(char *)parm_ptr
= *pszParmValue
;
1740 sscanf(pszParmValue
,"%o",(int *)parm_ptr
);
1744 string_set(parm_ptr
,pszParmValue
);
1748 string_set(parm_ptr
,pszParmValue
);
1749 strupper(*(char **)parm_ptr
);
1753 strcpy((char *)parm_ptr
,pszParmValue
);
1757 strcpy((char *)parm_ptr
,pszParmValue
);
1758 strupper((char *)parm_ptr
);
1765 /***************************************************************************
1766 Process a parameter.
1767 ***************************************************************************/
1768 static BOOL
do_parameter(char *pszParmName
, char *pszParmValue
)
1770 if (!bInGlobalSection
&& bGlobalOnly
) return(True
);
1772 DEBUG(3,("doing parameter %s = %s\n",pszParmName
,pszParmValue
));
1774 return lp_do_parameter(bInGlobalSection
?-2:iServiceIndex
, pszParmName
, pszParmValue
);
1778 /***************************************************************************
1779 print a parameter of the specified type
1780 ***************************************************************************/
1781 static void print_parameter(parm_type type
,void *ptr
, FILE *f
)
1786 fprintf(f
,"%s",BOOLSTR(*(BOOL
*)ptr
));
1790 fprintf(f
,"%s",BOOLSTR(! *(BOOL
*)ptr
));
1794 fprintf(f
,"%d",*(int *)ptr
);
1798 fprintf(f
,"%c",*(char *)ptr
);
1802 fprintf(f
,"0%o",*(int *)ptr
);
1808 fprintf(f
,"%s",(char *)ptr
);
1814 fprintf(f
,"%s",*(char **)ptr
);
1820 /***************************************************************************
1821 print a parameter of the specified type
1822 ***************************************************************************/
1823 static void parameter_string(parm_type type
,void *ptr
,char *s
)
1830 sprintf(s
, "%s",BOOLSTR(*(BOOL
*)ptr
));
1834 sprintf(s
, "%s",BOOLSTR(! *(BOOL
*)ptr
));
1838 sprintf(s
, "%d",*(int *)ptr
);
1842 sprintf(s
, "%c",*(char *)ptr
);
1846 sprintf(s
, "0%o",*(int *)ptr
);
1852 sprintf(s
, "%s",(char *)ptr
);
1858 sprintf(s
, "%s",*(char **)ptr
);
1864 /***************************************************************************
1865 check if two parameters are equal
1866 ***************************************************************************/
1867 static BOOL
equal_parameter(parm_type type
,void *ptr1
,void *ptr2
)
1873 return(*((BOOL
*)ptr1
) == *((BOOL
*)ptr2
));
1877 return(*((int *)ptr1
) == *((int *)ptr2
));
1880 return(*((char *)ptr1
) == *((char *)ptr2
));
1885 char *p1
= (char *)ptr1
, *p2
= (char *)ptr2
;
1886 if (p1
&& !*p1
) p1
= NULL
;
1887 if (p2
&& !*p2
) p2
= NULL
;
1888 return(p1
==p2
|| strequal(p1
,p2
));
1893 char *p1
= *(char **)ptr1
, *p2
= *(char **)ptr2
;
1894 if (p1
&& !*p1
) p1
= NULL
;
1895 if (p2
&& !*p2
) p2
= NULL
;
1896 return(p1
==p2
|| strequal(p1
,p2
));
1902 /***************************************************************************
1903 Process a new section (service). At this stage all sections are services.
1904 Later we'll have special sections that permit server parameters to be set.
1905 Returns True on success, False on failure.
1906 ***************************************************************************/
1907 static BOOL
do_section(char *pszSectionName
)
1910 BOOL isglobal
= ((strwicmp(pszSectionName
, GLOBAL_NAME
) == 0) ||
1911 (strwicmp(pszSectionName
, GLOBAL_NAME2
) == 0));
1914 /* if we were in a global section then do the local inits */
1915 if (bInGlobalSection
&& !isglobal
)
1918 /* if we've just struck a global section, note the fact. */
1919 bInGlobalSection
= isglobal
;
1921 /* check for multiple global sections */
1922 if (bInGlobalSection
)
1924 DEBUG(3,( "Processing section \"[%s]\"\n", pszSectionName
));
1928 if (!bInGlobalSection
&& bGlobalOnly
) return(True
);
1930 /* if we have a current service, tidy it up before moving on */
1933 if (iServiceIndex
>= 0)
1934 bRetval
= service_ok(iServiceIndex
);
1936 /* if all is still well, move to the next record in the services array */
1939 /* We put this here to avoid an odd message order if messages are */
1940 /* issued by the post-processing of a previous section. */
1941 DEBUG(2,( "Processing section \"[%s]\"\n", pszSectionName
));
1943 if ((iServiceIndex
=add_a_service(&sDefault
,pszSectionName
)) < 0)
1945 DEBUG(0,("Failed to add a new service\n"));
1953 /***************************************************************************
1954 Display the contents of the global structure.
1955 ***************************************************************************/
1956 static void dump_globals(FILE *f
)
1959 fprintf(f
, "# Global parameters\n");
1961 for (i
=0;parm_table
[i
].label
;i
++)
1962 if (parm_table
[i
].class == P_GLOBAL
&&
1963 parm_table
[i
].ptr
&&
1964 (i
== 0 || (parm_table
[i
].ptr
!= parm_table
[i
-1].ptr
)))
1966 fprintf(f
,"\t%s = ",parm_table
[i
].label
);
1967 print_parameter(parm_table
[i
].type
,parm_table
[i
].ptr
, f
);
1972 /***************************************************************************
1973 Display the contents of a single services record.
1974 ***************************************************************************/
1975 static void dump_a_service(service
*pService
, FILE *f
)
1978 if (pService
== &sDefault
)
1979 fprintf(f
,"\n\n# Default service parameters\n");
1981 fprintf(f
,"\n[%s]\n",pService
->szService
);
1983 for (i
=0;parm_table
[i
].label
;i
++)
1984 if (parm_table
[i
].class == P_LOCAL
&&
1985 parm_table
[i
].ptr
&&
1986 (*parm_table
[i
].label
!= '-') &&
1987 (i
== 0 || (parm_table
[i
].ptr
!= parm_table
[i
-1].ptr
)))
1989 int pdiff
= PTR_DIFF(parm_table
[i
].ptr
,&sDefault
);
1991 if (pService
== &sDefault
|| !equal_parameter(parm_table
[i
].type
,
1992 ((char *)pService
) + pdiff
,
1993 ((char *)&sDefault
) + pdiff
))
1995 fprintf(f
,"\t%s = ",parm_table
[i
].label
);
1996 print_parameter(parm_table
[i
].type
,
1997 ((char *)pService
) + pdiff
, f
);
2004 /***************************************************************************
2005 return info about the next service in a service. snum==-1 gives the default
2006 serice and snum==-2 gives the globals
2008 return 0 when out of parameters
2009 ***************************************************************************/
2010 int lp_next_parameter(int snum
, int *i
, char *label
,
2011 char *value
, int allparameters
)
2014 /* do the globals */
2015 for (;parm_table
[*i
].label
;(*i
)++)
2016 if (parm_table
[*i
].class == P_GLOBAL
&&
2017 parm_table
[*i
].ptr
&&
2018 (*parm_table
[*i
].label
!= '-') &&
2020 (parm_table
[*i
].ptr
!= parm_table
[(*i
)-1].ptr
))) {
2021 strcpy(label
, parm_table
[*i
].label
);
2022 parameter_string(parm_table
[*i
].type
,
2030 service
*pService
= (snum
==-1?&sDefault
:pSERVICE(snum
));
2032 for (;parm_table
[*i
].label
;(*i
)++)
2033 if (parm_table
[*i
].class == P_LOCAL
&&
2034 parm_table
[*i
].ptr
&&
2035 (*parm_table
[*i
].label
!= '-') &&
2037 (parm_table
[*i
].ptr
!= parm_table
[(*i
)-1].ptr
))) {
2038 int pdiff
= PTR_DIFF(parm_table
[*i
].ptr
,&sDefault
);
2040 if (snum
== -1 || allparameters
||
2041 !equal_parameter(parm_table
[*i
].type
,
2042 ((char *)pService
) + pdiff
,
2043 ((char *)&sDefault
) + pdiff
)) {
2044 strcpy(label
, parm_table
[*i
].label
);
2045 parameter_string(parm_table
[*i
].type
,
2046 ((char *)pService
) + pdiff
,
2059 /***************************************************************************
2060 Display the contents of a single copy structure.
2061 ***************************************************************************/
2062 static void dump_copy_map(BOOL
*pcopymap
)
2065 if (!pcopymap
) return;
2067 printf("\n\tNon-Copied parameters:\n");
2069 for (i
=0;parm_table
[i
].label
;i
++)
2070 if (parm_table
[i
].class == P_LOCAL
&&
2071 parm_table
[i
].ptr
&& !pcopymap
[i
] &&
2072 (i
== 0 || (parm_table
[i
].ptr
!= parm_table
[i
-1].ptr
)))
2074 printf("\t\t%s\n",parm_table
[i
].label
);
2079 /***************************************************************************
2080 Return TRUE if the passed service number is within range.
2081 ***************************************************************************/
2082 BOOL
lp_snum_ok(int iService
)
2084 return (LP_SNUM_OK(iService
) && iSERVICE(iService
).bAvailable
);
2088 /***************************************************************************
2089 auto-load some homes and printer services
2090 ***************************************************************************/
2091 static void lp_add_auto_services(char *str
)
2095 int homes
= lp_servicenumber(HOMES_NAME
);
2096 int printers
= lp_servicenumber(PRINTERS_NAME
);
2104 for (p
=strtok(s
,LIST_SEP
);p
;p
=strtok(NULL
,LIST_SEP
))
2106 char *home
= get_home_dir(p
);
2108 if (lp_servicenumber(p
) >= 0) continue;
2110 if (home
&& homes
>= 0)
2112 lp_add_home(p
,homes
,home
);
2116 if (printers
>= 0 && pcap_printername_ok(p
,NULL
))
2117 lp_add_printer(p
,printers
);
2122 /***************************************************************************
2123 auto-load one printer
2124 ***************************************************************************/
2125 static void lp_add_one_printer(char *name
,char *comment
)
2127 int printers
= lp_servicenumber(PRINTERS_NAME
);
2130 if (lp_servicenumber(name
) < 0)
2132 lp_add_printer(name
,printers
);
2133 if ((i
=lp_servicenumber(name
)) >= 0)
2134 string_set(&iSERVICE(i
).comment
,comment
);
2139 /***************************************************************************
2140 auto-load printer services
2141 ***************************************************************************/
2142 static void lp_add_all_printers(void)
2144 int printers
= lp_servicenumber(PRINTERS_NAME
);
2146 if (printers
< 0) return;
2148 pcap_printer_fn(lp_add_one_printer
);
2151 /***************************************************************************
2152 have we loaded a services file yet?
2153 ***************************************************************************/
2154 BOOL
lp_loaded(void)
2159 /***************************************************************************
2160 unload unused services
2161 ***************************************************************************/
2162 void lp_killunused(BOOL (*snumused
)(int ))
2165 for (i
=0;i
<iNumServices
;i
++)
2166 if (VALID(i
) && (!snumused
|| !snumused(i
)))
2168 iSERVICE(i
).valid
= False
;
2169 free_service(pSERVICE(i
));
2173 /***************************************************************************
2174 Load the services array from the services file. Return True on success,
2176 ***************************************************************************/
2177 BOOL
lp_load(char *pszFname
,BOOL global_only
)
2182 add_to_file_list(pszFname
);
2186 bInGlobalSection
= True
;
2187 bGlobalOnly
= global_only
;
2191 pstrcpy(n2
,pszFname
);
2192 standard_sub_basic(n2
);
2194 /* We get sections first, so have to start 'behind' to make up */
2196 bRetval
= pm_process(n2
, do_section
, do_parameter
);
2198 /* finish up the last section */
2199 DEBUG(3,("pm_process() returned %s\n", BOOLSTR(bRetval
)));
2201 if (iServiceIndex
>= 0)
2202 bRetval
= service_ok(iServiceIndex
);
2204 lp_add_auto_services(lp_auto_services());
2205 if (lp_load_printers())
2206 lp_add_all_printers();
2210 set_default_server_announce_type();
2218 /***************************************************************************
2219 return the max number of services
2220 ***************************************************************************/
2221 int lp_numservices(void)
2223 return(iNumServices
);
2226 /***************************************************************************
2227 Display the contents of the services array in human-readable form.
2228 ***************************************************************************/
2229 void lp_dump(FILE *f
)
2235 dump_a_service(&sDefault
, f
);
2237 for (iService
= 0; iService
< iNumServices
; iService
++)
2239 if (VALID(iService
))
2241 if (iSERVICE(iService
).szService
[0] == '\0')
2243 dump_a_service(pSERVICE(iService
), f
);
2249 /***************************************************************************
2250 Return the number of the service with the given name, or -1 if it doesn't
2251 exist. Note that this is a DIFFERENT ANIMAL from the internal function
2252 getservicebyname()! This works ONLY if all services have been loaded, and
2253 does not copy the found service.
2254 ***************************************************************************/
2255 int lp_servicenumber(char *pszServiceName
)
2259 for (iService
= iNumServices
- 1; iService
>= 0; iService
--)
2260 if (VALID(iService
) &&
2261 strwicmp(iSERVICE(iService
).szService
, pszServiceName
) == 0)
2265 DEBUG(7,("lp_servicenumber: couldn't find %s\n",pszServiceName
));
2270 /*******************************************************************
2271 a useful volume label function
2272 ******************************************************************/
2273 char *volume_label(int snum
)
2275 char *ret
= lp_volume(snum
);
2276 if (!*ret
) return(lp_servicename(snum
));
2282 * nmbd only loads the global section. There seems to be no way to
2283 * determine exactly is a service is printable by only looking at the
2284 * [global] section so for now always announce as a print server. This
2285 * will need looking at in the future. Jeremy (jallison@whistle.com).
2287 /*******************************************************************
2288 Return true if any printer services are defined.
2289 ******************************************************************/
2290 static BOOL
lp_printer_services(void)
2294 for (iService
= iNumServices
- 1; iService
>= 0; iService
--)
2295 if (VALID(iService
) && iSERVICE(iService
).bPrint_ok
)
2301 /*******************************************************************
2302 Set the server type we will announce as via nmbd.
2303 ********************************************************************/
2304 static void set_default_server_announce_type()
2306 default_server_announce
= (SV_TYPE_WORKSTATION
| SV_TYPE_SERVER
|
2307 SV_TYPE_SERVER_UNIX
| SV_TYPE_PRINTQ_SERVER
);
2308 if(lp_announce_as() == ANNOUNCE_AS_NT
)
2309 default_server_announce
|= (SV_TYPE_SERVER_NT
| SV_TYPE_NT
);
2310 else if(lp_announce_as() == ANNOUNCE_AS_WIN95
)
2311 default_server_announce
|= SV_TYPE_WIN95_PLUS
;
2312 else if(lp_announce_as() == ANNOUNCE_AS_WFW
)
2313 default_server_announce
|= SV_TYPE_WFW
;
2314 default_server_announce
|= (lp_time_server() ? SV_TYPE_TIME_SOURCE
: 0);
2316 * nmbd only loads the [global] section. There seems to be no way to
2317 * determine exactly if any service is printable by only looking at the
2318 * [global] section so for now always announce as a print server. This
2319 * will need looking at in the future. Jeremy (jallison@whistle.com).
2322 default_server_announce
|= (lp_printer_services() ? SV_TYPE_PRINTQ_SERVER
: 0);
2327 /*******************************************************************
2329 ********************************************************************/
2330 void lp_rename_service(int snum
, char *new_name
)
2332 string_set(&pSERVICE(snum
)->szService
, new_name
);
2335 /*******************************************************************
2337 ********************************************************************/
2338 void lp_remove_service(int snum
)
2340 pSERVICE(snum
)->valid
= False
;
2343 /*******************************************************************
2345 ********************************************************************/
2346 void lp_copy_service(int snum
, char *new_name
)
2348 char *oldname
= lp_servicename(snum
);
2349 do_section(new_name
);
2351 snum
= lp_servicenumber(new_name
);
2353 lp_do_parameter(snum
, "copy", oldname
);
2358 /*******************************************************************
2359 Get the default server type we will announce as via nmbd.
2360 ********************************************************************/
2361 int lp_default_server_announce(void)
2363 return default_server_announce
;
2366 /*******************************************************************
2367 Split the announce version into major and minor numbers.
2368 ********************************************************************/
2369 int lp_major_announce_version(void)
2371 static BOOL got_major
= False
;
2372 static int major_version
= DEFAULT_MAJOR_VERSION
;
2377 return major_version
;
2380 if((vers
= lp_announce_version()) == NULL
)
2381 return major_version
;
2383 if((p
= strchr(vers
, '.')) == 0)
2384 return major_version
;
2387 major_version
= atoi(vers
);
2388 return major_version
;
2391 int lp_minor_announce_version(void)
2393 static BOOL got_minor
= False
;
2394 static int minor_version
= DEFAULT_MINOR_VERSION
;
2399 return minor_version
;
2402 if((vers
= lp_announce_version()) == NULL
)
2403 return minor_version
;
2405 if((p
= strchr(vers
, '.')) == 0)
2406 return minor_version
;
2409 minor_version
= atoi(p
);
2410 return minor_version
;