2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
Parameter loading functions
Copyright ( C ) Karl Auer 1993 - 1998
Largely re - written by Andrew Tridgell , September 1994
Copyright ( C ) Simo Sorce 2001
Copyright ( C ) Alexander Bokovoy 2002
Copyright ( C ) Stefan ( metze ) Metzmacher 2002
2004-07-28 17:08:08 +04:00
Copyright ( C ) Jim McDonough ( jmcd @ us . ibm . com ) 2003.
2003-08-13 05:53:07 +04:00
Copyright ( C ) James Myers 2003 < myersjj @ samba . org >
2007-09-08 04:07:50 +04:00
Copyright ( C ) Jelmer Vernooij < jelmer @ samba . org > 2007
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +04:00
( at your option ) any later version .
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
/*
* Load parameters .
*
* This module provides suitable callback functions for the params
* module . It builds the internal table of service details which is
* then used by the rest of the server .
*
* To add a parameter :
*
* 1 ) add it to the global or service structure definition
* 2 ) add it to the parm_table
* 3 ) add it to the list of available functions ( eg : using FN_GLOBAL_STRING ( ) )
* 4 ) If it ' s a global then initialise it in init_globals . If a local
* ( ie . service ) parameter then initialise it in the sDefault structure
2008-02-10 15:01:20 +03:00
*
2003-08-13 05:53:07 +04:00
*
* Notes :
* The configuration file is processed sequentially for speed . It is NOT
* accessed randomly as happens in ' real ' Windows . For this reason , there
* is a fair bit of sequence - dependent code here - ie . , code which assumes
* that certain things happen before others . In particular , the code which
* happens at the boundary between sections is delicately poised , so be
* careful !
*
*/
# include "includes.h"
2005-01-18 12:30:43 +03:00
# include "version.h"
2008-05-27 16:36:28 +04:00
# include "dynconfig/dynconfig.h"
2004-11-02 03:24:21 +03:00
# include "system/time.h"
2006-05-13 23:14:12 +04:00
# include "system/locale.h"
2006-08-14 13:58:50 +04:00
# include "system/network.h" /* needed for TCP_NODELAY */
2006-02-23 18:52:24 +03:00
# include "smb_server/smb_server.h"
# include "libcli/raw/signing.h"
2008-10-11 23:31:42 +04:00
# include "../lib/util/dlinklist.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2005-05-27 11:14:01 +04:00
# include "param/loadparm.h"
2008-01-04 02:22:12 +03:00
# include "libcli/raw/libcliraw.h"
2003-08-13 05:53:07 +04:00
2007-09-08 04:48:23 +04:00
# define standard_sub_basic talloc_strdup
2006-07-10 22:15:24 +04:00
2007-09-08 03:37:00 +04:00
static bool do_parameter ( const char * , const char * , void * ) ;
2007-09-08 04:07:50 +04:00
static bool defaults_saved = false ;
2003-08-13 05:53:07 +04:00
2007-12-07 18:04:17 +03:00
/**
2003-08-13 05:53:07 +04:00
* This structure describes global ( ie . , server - wide ) parameters .
*/
2007-09-24 22:47:50 +04:00
struct loadparm_global
2003-08-13 05:53:07 +04:00
{
2007-09-08 04:07:50 +04:00
enum server_role server_role ;
2005-09-19 15:55:34 +04:00
2007-09-28 05:17:46 +04:00
const char * * smb_ports ;
2004-10-24 18:57:16 +04:00
char * ncalrpc_dir ;
2007-10-02 03:26:37 +04:00
char * dos_charset ;
char * unix_charset ;
char * display_charset ;
2003-08-13 05:53:07 +04:00
char * szLockDir ;
2006-04-04 20:20:32 +04:00
char * szModulesDir ;
2003-08-13 05:53:07 +04:00
char * szPidDir ;
2005-07-12 09:57:14 +04:00
char * szSetupDir ;
2003-08-13 05:53:07 +04:00
char * szServerString ;
char * szAutoServices ;
char * szPasswdChat ;
2006-07-23 22:43:07 +04:00
char * szShareBackend ;
2004-05-03 18:58:08 +04:00
char * szSAM_URL ;
2008-02-17 22:25:13 +03:00
char * szIDMAP_URL ;
2007-01-15 17:17:26 +03:00
char * szSECRETS_URL ;
2004-06-21 10:55:01 +04:00
char * szSPOOLSS_URL ;
2005-12-17 18:45:38 +03:00
char * szWINS_CONFIG_URL ;
2005-02-12 02:54:37 +03:00
char * szWINS_URL ;
2003-08-13 05:53:07 +04:00
char * szPrivateDir ;
2007-09-28 05:17:46 +04:00
const char * * szPasswordServers ;
2003-08-13 05:53:07 +04:00
char * szSocketOptions ;
char * szRealm ;
2007-09-28 05:17:46 +04:00
const char * * szWINSservers ;
const char * * szInterfaces ;
2003-08-13 05:53:07 +04:00
char * szSocketAddress ;
char * szAnnounceVersion ; /* This is initialised in init_globals */
char * szWorkgroup ;
char * szNetbiosName ;
2007-09-28 05:17:46 +04:00
const char * * szNetbiosAliases ;
2003-08-13 05:53:07 +04:00
char * szNetbiosScope ;
char * szDomainOtherSIDs ;
2007-09-28 05:17:46 +04:00
const char * * szNameResolveOrder ;
const char * * dcerpc_ep_servers ;
const char * * server_services ;
r7643: This patch adds a new NTPTR subsystem:
- this is an abstraction layer for print services,
like out NTVFS subsystem for file services
- all protocol specific details are still in rpc_server/spoolss/
- like the stupid in and out Buffer handling
- checking of the r->in.server_name
- ...
- this subsystem can have multiple implementation
selected by the "ntptr providor" global-section parameter
- I currently added a "simple_ldb" backend,
that stores Printers, Forms, Ports, Monitors, ...
in the spoolss.db, and does no real printing
this backend is basicly for testing, how the spoolss protocol
works
- the interface is just a prototype and will be changed a bit
the next days or weeks, till the simple_ldb backend can
handle all calls that are used by normal w2k3/xp clients
- I'll also make the api async, as the ntvfs api
this will make things like the RemoteFindFirstPrinterChangeNotifyEx(),
that opens a connection back to the client, easier to implement,
as we should not block the whole smbd for that
- the idea is to later implement a "unix" backend
that works like the current samba3 code
- and maybe some embedded print server vendors can write there own
backend that can directly talk to a printer without having cups or something like this
- the default settings are (it currently makes no sense to change them :-):
ntptr providor = simple_ldb
spoolss database = $private_dir/spoolss.db
metze
(This used to be commit 455b5536d41bc31ebef8290812f45d4a38afa8e9)
2005-06-16 21:27:57 +04:00
char * ntptr_providor ;
2003-08-13 05:53:07 +04:00
char * szWinbindSeparator ;
2008-06-28 16:02:19 +04:00
char * szWinbinddPrivilegedSocketDirectory ;
2006-01-31 03:48:57 +03:00
char * szWinbinddSocketDirectory ;
2007-08-13 18:43:18 +04:00
char * szTemplateShell ;
char * szTemplateHomedir ;
2007-10-02 19:02:19 +04:00
int bWinbindSealedPipes ;
2008-02-17 22:25:13 +03:00
int bIdmapTrustedOnly ;
2007-09-10 07:44:47 +04:00
char * swat_directory ;
2007-10-02 19:02:19 +04:00
int tls_enabled ;
2005-06-19 08:21:45 +04:00
char * tls_keyfile ;
char * tls_certfile ;
char * tls_cafile ;
char * tls_crlfile ;
2006-08-03 12:02:54 +04:00
char * tls_dhpfile ;
2007-12-07 18:04:22 +03:00
char * logfile ;
char * panic_action ;
2003-08-13 05:53:07 +04:00
int max_mux ;
2007-12-07 18:04:22 +03:00
int debuglevel ;
2004-03-23 06:17:38 +03:00
int max_xmit ;
2003-08-13 05:53:07 +04:00
int pwordlevel ;
2006-06-22 21:06:36 +04:00
int srv_maxprotocol ;
int srv_minprotocol ;
int cli_maxprotocol ;
int cli_minprotocol ;
2007-10-02 19:02:19 +04:00
int security ;
int paranoid_server_security ;
2003-08-13 05:53:07 +04:00
int max_wins_ttl ;
int min_wins_ttl ;
int announce_as ; /* This is initialised in init_globals */
2005-01-30 13:24:36 +03:00
int nbt_port ;
2005-04-03 08:32:37 +04:00
int dgram_port ;
2005-05-11 08:48:30 +04:00
int cldap_port ;
2005-06-03 15:23:15 +04:00
int krb5_port ;
2005-10-21 05:25:55 +04:00
int kpasswd_port ;
2005-05-26 06:06:33 +04:00
int web_port ;
2003-08-13 05:53:07 +04:00
char * socket_options ;
2007-10-02 19:02:19 +04:00
int bWINSsupport ;
int bWINSdnsProxy ;
2008-02-10 15:01:20 +03:00
char * szWINSHook ;
2007-10-02 19:02:19 +04:00
int bLocalMaster ;
int bPreferredMaster ;
int bEncryptPasswords ;
int bNullPasswords ;
int bObeyPamRestrictions ;
int bLargeReadwrite ;
int bReadRaw ;
int bWriteRaw ;
int bTimeServer ;
int bBindInterfacesOnly ;
int bNTSmbSupport ;
int bNTStatusSupport ;
int bLanmanAuth ;
int bNTLMAuth ;
int bUseSpnego ;
2007-08-29 17:07:03 +04:00
int server_signing ;
int client_signing ;
2007-10-02 19:02:19 +04:00
int bClientPlaintextAuth ;
int bClientLanManAuth ;
int bClientNTLMv2Auth ;
int client_use_spnego_principal ;
int bHostMSDfs ;
int bUnicode ;
int bUnixExtensions ;
int bDisableNetbios ;
int bRpcBigEndian ;
2008-05-29 09:20:58 +04:00
char * szNTPSignDSocketDirectory ;
2003-08-13 05:53:07 +04:00
struct param_opt * param_opt ;
2007-09-08 05:29:52 +04:00
} ;
2003-08-13 05:53:07 +04:00
2007-12-07 18:04:17 +03:00
/**
2008-02-10 15:01:20 +03:00
* This structure describes a single service .
2003-08-13 05:53:07 +04:00
*/
2007-09-09 00:03:19 +04:00
struct loadparm_service
2003-08-13 05:53:07 +04:00
{
char * szService ;
char * szPath ;
char * szCopy ;
char * szInclude ;
char * szPrintername ;
char * * szHostsallow ;
char * * szHostsdeny ;
char * comment ;
char * volume ;
char * fstype ;
2004-09-23 11:44:42 +04:00
char * * ntvfs_handler ;
2003-08-13 05:53:07 +04:00
int iMaxPrintJobs ;
int iMaxConnections ;
int iCSCPolicy ;
2006-04-01 22:25:07 +04:00
int bAvailable ;
int bBrowseable ;
int bRead_only ;
int bPrint_ok ;
int bMap_system ;
int bMap_hidden ;
int bMap_archive ;
int bStrictLocking ;
2008-03-27 12:32:02 +03:00
int bOplocks ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
int iCreate_mask ;
int iCreate_force_mode ;
int iDir_mask ;
int iDir_force_mode ;
2006-04-01 22:25:07 +04:00
int * copymap ;
int bMSDfsRoot ;
int bStrictSync ;
int bCIFileSystem ;
2003-08-13 05:53:07 +04:00
struct param_opt * param_opt ;
char dummy [ 3 ] ; /* for alignment */
2007-09-08 05:29:52 +04:00
} ;
2003-08-13 05:53:07 +04:00
2007-12-09 01:31:41 +03:00
struct loadparm_context * global_loadparm = NULL ;
2003-08-13 05:53:07 +04:00
# define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
2008-02-28 22:04:58 +03:00
2003-08-13 05:53:07 +04:00
/* prototypes for the special type handlers */
2008-02-10 15:01:20 +03:00
static bool handle_include ( struct loadparm_context * lp_ctx ,
2007-09-09 00:49:43 +04:00
const char * pszParmValue , char * * ptr ) ;
2008-02-10 15:01:20 +03:00
static bool handle_copy ( struct loadparm_context * lp_ctx ,
2007-09-09 00:49:43 +04:00
const char * pszParmValue , char * * ptr ) ;
2007-12-09 01:31:49 +03:00
static bool handle_debuglevel ( struct loadparm_context * lp_ctx ,
const char * pszParmValue , char * * ptr ) ;
static bool handle_logfile ( struct loadparm_context * lp_ctx ,
const char * pszParmValue , char * * ptr ) ;
2003-08-13 05:53:07 +04:00
static const struct enum_list enum_protocol [ ] = {
2006-03-06 17:19:11 +03:00
{ PROTOCOL_SMB2 , " SMB2 " } ,
2003-08-13 05:53:07 +04:00
{ PROTOCOL_NT1 , " NT1 " } ,
{ PROTOCOL_LANMAN2 , " LANMAN2 " } ,
{ PROTOCOL_LANMAN1 , " LANMAN1 " } ,
{ PROTOCOL_CORE , " CORE " } ,
{ PROTOCOL_COREPLUS , " COREPLUS " } ,
{ PROTOCOL_COREPLUS , " CORE+ " } ,
{ - 1 , NULL }
} ;
static const struct enum_list enum_security [ ] = {
{ SEC_SHARE , " SHARE " } ,
{ SEC_USER , " USER " } ,
{ - 1 , NULL }
} ;
static const struct enum_list enum_announce_as [ ] = {
{ ANNOUNCE_AS_NT_SERVER , " NT " } ,
{ ANNOUNCE_AS_NT_SERVER , " NT Server " } ,
{ ANNOUNCE_AS_NT_WORKSTATION , " NT Workstation " } ,
{ ANNOUNCE_AS_WIN95 , " win95 " } ,
{ ANNOUNCE_AS_WFW , " WfW " } ,
{ - 1 , NULL }
} ;
static const struct enum_list enum_bool_auto [ ] = {
2007-09-08 18:12:45 +04:00
{ false , " No " } ,
{ false , " False " } ,
{ false , " 0 " } ,
{ true , " Yes " } ,
{ true , " True " } ,
{ true , " 1 " } ,
2003-08-13 05:53:07 +04:00
{ Auto , " Auto " } ,
{ - 1 , NULL }
} ;
/* Client-side offline caching policy types */
2008-02-10 15:01:20 +03:00
enum csc_policy {
CSC_POLICY_MANUAL = 0 ,
CSC_POLICY_DOCUMENTS = 1 ,
2007-10-02 17:30:10 +04:00
CSC_POLICY_PROGRAMS = 2 ,
CSC_POLICY_DISABLE = 3
} ;
2003-08-13 05:53:07 +04:00
static const struct enum_list enum_csc_policy [ ] = {
{ CSC_POLICY_MANUAL , " manual " } ,
{ CSC_POLICY_DOCUMENTS , " documents " } ,
{ CSC_POLICY_PROGRAMS , " programs " } ,
{ CSC_POLICY_DISABLE , " disable " } ,
{ - 1 , NULL }
} ;
2004-05-22 15:16:21 +04:00
/* SMB signing types. */
static const struct enum_list enum_smb_signing_vals [ ] = {
{ SMB_SIGNING_OFF , " No " } ,
{ SMB_SIGNING_OFF , " False " } ,
{ SMB_SIGNING_OFF , " 0 " } ,
{ SMB_SIGNING_OFF , " Off " } ,
{ SMB_SIGNING_OFF , " disabled " } ,
{ SMB_SIGNING_SUPPORTED , " Yes " } ,
{ SMB_SIGNING_SUPPORTED , " True " } ,
{ SMB_SIGNING_SUPPORTED , " 1 " } ,
{ SMB_SIGNING_SUPPORTED , " On " } ,
{ SMB_SIGNING_SUPPORTED , " enabled " } ,
{ SMB_SIGNING_REQUIRED , " required " } ,
{ SMB_SIGNING_REQUIRED , " mandatory " } ,
{ SMB_SIGNING_REQUIRED , " force " } ,
{ SMB_SIGNING_REQUIRED , " forced " } ,
{ SMB_SIGNING_REQUIRED , " enforced " } ,
2004-10-30 05:22:52 +04:00
{ SMB_SIGNING_AUTO , " auto " } ,
2004-05-22 15:16:21 +04:00
{ - 1 , NULL }
} ;
2005-09-19 15:55:34 +04:00
static const struct enum_list enum_server_role [ ] = {
{ ROLE_STANDALONE , " standalone " } ,
{ ROLE_DOMAIN_MEMBER , " member server " } ,
2008-03-07 02:57:52 +03:00
{ ROLE_DOMAIN_MEMBER , " member " } ,
2006-12-13 14:19:51 +03:00
{ ROLE_DOMAIN_CONTROLLER , " domain controller " } ,
2008-03-07 02:57:52 +03:00
{ ROLE_DOMAIN_CONTROLLER , " dc " } ,
2005-09-19 15:55:34 +04:00
{ - 1 , NULL }
} ;
2003-08-13 05:53:07 +04:00
2007-12-07 18:04:22 +03:00
# define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
# define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
2007-10-02 22:40:37 +04:00
2003-08-13 05:53:07 +04:00
static struct parm_struct parm_table [ ] = {
2007-12-09 01:32:33 +03:00
{ " server role " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( server_role ) , NULL , enum_server_role } ,
{ " dos charset " , P_STRING , P_GLOBAL , GLOBAL_VAR ( dos_charset ) , NULL , NULL } ,
{ " unix charset " , P_STRING , P_GLOBAL , GLOBAL_VAR ( unix_charset ) , NULL , NULL } ,
{ " ncalrpc dir " , P_STRING , P_GLOBAL , GLOBAL_VAR ( ncalrpc_dir ) , NULL , NULL } ,
{ " display charset " , P_STRING , P_GLOBAL , GLOBAL_VAR ( display_charset ) , NULL , NULL } ,
{ " comment " , P_STRING , P_LOCAL , LOCAL_VAR ( comment ) , NULL , NULL } ,
{ " path " , P_STRING , P_LOCAL , LOCAL_VAR ( szPath ) , NULL , NULL } ,
{ " directory " , P_STRING , P_LOCAL , LOCAL_VAR ( szPath ) , NULL , NULL } ,
{ " workgroup " , P_USTRING , P_GLOBAL , GLOBAL_VAR ( szWorkgroup ) , NULL , NULL } ,
{ " realm " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szRealm ) , NULL , NULL } ,
{ " netbios name " , P_USTRING , P_GLOBAL , GLOBAL_VAR ( szNetbiosName ) , NULL , NULL } ,
{ " netbios aliases " , P_LIST , P_GLOBAL , GLOBAL_VAR ( szNetbiosAliases ) , NULL , NULL } ,
{ " netbios scope " , P_USTRING , P_GLOBAL , GLOBAL_VAR ( szNetbiosScope ) , NULL , NULL } ,
{ " server string " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szServerString ) , NULL , NULL } ,
{ " interfaces " , P_LIST , P_GLOBAL , GLOBAL_VAR ( szInterfaces ) , NULL , NULL } ,
{ " bind interfaces only " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bBindInterfacesOnly ) , NULL , NULL } ,
{ " ntvfs handler " , P_LIST , P_LOCAL , LOCAL_VAR ( ntvfs_handler ) , NULL , NULL } ,
{ " ntptr providor " , P_STRING , P_GLOBAL , GLOBAL_VAR ( ntptr_providor ) , NULL , NULL } ,
{ " dcerpc endpoint servers " , P_LIST , P_GLOBAL , GLOBAL_VAR ( dcerpc_ep_servers ) , NULL , NULL } ,
{ " server services " , P_LIST , P_GLOBAL , GLOBAL_VAR ( server_services ) , NULL , NULL } ,
{ " security " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( security ) , NULL , enum_security } ,
{ " encrypt passwords " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bEncryptPasswords ) , NULL , NULL } ,
{ " null passwords " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bNullPasswords ) , NULL , NULL } ,
{ " obey pam restrictions " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bObeyPamRestrictions ) , NULL , NULL } ,
{ " password server " , P_LIST , P_GLOBAL , GLOBAL_VAR ( szPasswordServers ) , NULL , NULL } ,
{ " sam database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szSAM_URL ) , NULL , NULL } ,
2008-02-17 22:25:13 +03:00
{ " idmap database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szIDMAP_URL ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " secrets database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szSECRETS_URL ) , NULL , NULL } ,
{ " spoolss database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szSPOOLSS_URL ) , NULL , NULL } ,
{ " wins config database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWINS_CONFIG_URL ) , NULL , NULL } ,
{ " wins database " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWINS_URL ) , NULL , NULL } ,
{ " private dir " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szPrivateDir ) , NULL , NULL } ,
{ " passwd chat " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szPasswdChat ) , NULL , NULL } ,
{ " password level " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( pwordlevel ) , NULL , NULL } ,
{ " lanman auth " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bLanmanAuth ) , NULL , NULL } ,
{ " ntlm auth " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bNTLMAuth ) , NULL , NULL } ,
{ " client NTLMv2 auth " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bClientNTLMv2Auth ) , NULL , NULL } ,
{ " client lanman auth " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bClientLanManAuth ) , NULL , NULL } ,
{ " client plaintext auth " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bClientPlaintextAuth ) , NULL , NULL } ,
{ " client use spnego principal " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( client_use_spnego_principal ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " read only " , P_BOOL , P_LOCAL , LOCAL_VAR ( bRead_only ) , NULL , NULL } ,
2004-01-29 12:47:39 +03:00
2008-02-10 15:01:20 +03:00
{ " create mask " , P_OCTAL , P_LOCAL , LOCAL_VAR ( iCreate_mask ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " force create mode " , P_OCTAL , P_LOCAL , LOCAL_VAR ( iCreate_force_mode ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
{ " directory mask " , P_OCTAL , P_LOCAL , LOCAL_VAR ( iDir_mask ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " force directory mode " , P_OCTAL , P_LOCAL , LOCAL_VAR ( iDir_force_mode ) , NULL , NULL } ,
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
2007-12-09 01:32:33 +03:00
{ " hosts allow " , P_LIST , P_LOCAL , LOCAL_VAR ( szHostsallow ) , NULL , NULL } ,
{ " hosts deny " , P_LIST , P_LOCAL , LOCAL_VAR ( szHostsdeny ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " log level " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( debuglevel ) , handle_debuglevel , NULL } ,
{ " debuglevel " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( debuglevel ) , handle_debuglevel , NULL } ,
{ " log file " , P_STRING , P_GLOBAL , GLOBAL_VAR ( logfile ) , handle_logfile , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " smb ports " , P_LIST , P_GLOBAL , GLOBAL_VAR ( smb_ports ) , NULL , NULL } ,
{ " nbt port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( nbt_port ) , NULL , NULL } ,
{ " dgram port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( dgram_port ) , NULL , NULL } ,
{ " cldap port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( cldap_port ) , NULL , NULL } ,
{ " krb5 port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( krb5_port ) , NULL , NULL } ,
{ " kpasswd port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( kpasswd_port ) , NULL , NULL } ,
{ " web port " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( web_port ) , NULL , NULL } ,
{ " tls enabled " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( tls_enabled ) , NULL , NULL } ,
{ " tls keyfile " , P_STRING , P_GLOBAL , GLOBAL_VAR ( tls_keyfile ) , NULL , NULL } ,
{ " tls certfile " , P_STRING , P_GLOBAL , GLOBAL_VAR ( tls_certfile ) , NULL , NULL } ,
{ " tls cafile " , P_STRING , P_GLOBAL , GLOBAL_VAR ( tls_cafile ) , NULL , NULL } ,
{ " tls crlfile " , P_STRING , P_GLOBAL , GLOBAL_VAR ( tls_crlfile ) , NULL , NULL } ,
{ " tls dh params file " , P_STRING , P_GLOBAL , GLOBAL_VAR ( tls_dhpfile ) , NULL , NULL } ,
{ " swat directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( swat_directory ) , NULL , NULL } ,
{ " large readwrite " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bLargeReadwrite ) , NULL , NULL } ,
{ " server max protocol " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( srv_maxprotocol ) , NULL , enum_protocol } ,
{ " server min protocol " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( srv_minprotocol ) , NULL , enum_protocol } ,
{ " client max protocol " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( cli_maxprotocol ) , NULL , enum_protocol } ,
{ " client min protocol " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( cli_minprotocol ) , NULL , enum_protocol } ,
{ " unicode " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bUnicode ) , NULL , NULL } ,
{ " read raw " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bReadRaw ) , NULL , NULL } ,
{ " write raw " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bWriteRaw ) , NULL , NULL } ,
{ " disable netbios " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bDisableNetbios ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " nt status support " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bNTStatusSupport ) , NULL , NULL } ,
{ " announce version " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szAnnounceVersion ) , NULL , NULL } ,
{ " announce as " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( announce_as ) , NULL , enum_announce_as } ,
{ " max mux " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( max_mux ) , NULL , NULL } ,
{ " max xmit " , P_BYTES , P_GLOBAL , GLOBAL_VAR ( max_xmit ) , NULL , NULL } ,
{ " name resolve order " , P_LIST , P_GLOBAL , GLOBAL_VAR ( szNameResolveOrder ) , NULL , NULL } ,
{ " max wins ttl " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( max_wins_ttl ) , NULL , NULL } ,
{ " min wins ttl " , P_INTEGER , P_GLOBAL , GLOBAL_VAR ( min_wins_ttl ) , NULL , NULL } ,
{ " time server " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bTimeServer ) , NULL , NULL } ,
{ " unix extensions " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bUnixExtensions ) , NULL , NULL } ,
{ " use spnego " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bUseSpnego ) , NULL , NULL } ,
{ " server signing " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( server_signing ) , NULL , enum_smb_signing_vals } ,
{ " client signing " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( client_signing ) , NULL , enum_smb_signing_vals } ,
{ " rpc big endian " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bRpcBigEndian ) , NULL , NULL } ,
{ " max connections " , P_INTEGER , P_LOCAL , LOCAL_VAR ( iMaxConnections ) , NULL , NULL } ,
{ " paranoid server security " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( paranoid_server_security ) , NULL , NULL } ,
{ " socket options " , P_STRING , P_GLOBAL , GLOBAL_VAR ( socket_options ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
{ " strict sync " , P_BOOL , P_LOCAL , LOCAL_VAR ( bStrictSync ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " case insensitive filesystem " , P_BOOL , P_LOCAL , LOCAL_VAR ( bCIFileSystem ) , NULL , NULL } ,
{ " max print jobs " , P_INTEGER , P_LOCAL , LOCAL_VAR ( iMaxPrintJobs ) , NULL , NULL } ,
{ " printable " , P_BOOL , P_LOCAL , LOCAL_VAR ( bPrint_ok ) , NULL , NULL } ,
{ " print ok " , P_BOOL , P_LOCAL , LOCAL_VAR ( bPrint_ok ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " printer name " , P_STRING , P_LOCAL , LOCAL_VAR ( szPrintername ) , NULL , NULL } ,
{ " printer " , P_STRING , P_LOCAL , LOCAL_VAR ( szPrintername ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " map system " , P_BOOL , P_LOCAL , LOCAL_VAR ( bMap_system ) , NULL , NULL } ,
{ " map hidden " , P_BOOL , P_LOCAL , LOCAL_VAR ( bMap_hidden ) , NULL , NULL } ,
{ " map archive " , P_BOOL , P_LOCAL , LOCAL_VAR ( bMap_archive ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " preferred master " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( bPreferredMaster ) , NULL , enum_bool_auto } ,
{ " prefered master " , P_ENUM , P_GLOBAL , GLOBAL_VAR ( bPreferredMaster ) , NULL , enum_bool_auto } ,
{ " local master " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bLocalMaster ) , NULL , NULL } ,
{ " browseable " , P_BOOL , P_LOCAL , LOCAL_VAR ( bBrowseable ) , NULL , NULL } ,
{ " browsable " , P_BOOL , P_LOCAL , LOCAL_VAR ( bBrowseable ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " wins server " , P_LIST , P_GLOBAL , GLOBAL_VAR ( szWINSservers ) , NULL , NULL } ,
{ " wins support " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bWINSsupport ) , NULL , NULL } ,
{ " dns proxy " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bWINSdnsProxy ) , NULL , NULL } ,
{ " wins hook " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWINSHook ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " csc policy " , P_ENUM , P_LOCAL , LOCAL_VAR ( iCSCPolicy ) , NULL , enum_csc_policy } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " strict locking " , P_BOOL , P_LOCAL , LOCAL_VAR ( bStrictLocking ) , NULL , NULL } ,
2008-03-28 02:18:06 +03:00
{ " oplocks " , P_BOOL , P_LOCAL , LOCAL_VAR ( bOplocks ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " share backend " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szShareBackend ) , NULL , NULL } ,
{ " preload " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szAutoServices ) , NULL , NULL } ,
{ " auto services " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szAutoServices ) , NULL , NULL } ,
{ " lock dir " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szLockDir ) , NULL , NULL } ,
{ " lock directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szLockDir ) , NULL , NULL } ,
{ " modules dir " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szModulesDir ) , NULL , NULL } ,
{ " pid directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szPidDir ) , NULL , NULL } ,
{ " setup directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szSetupDir ) , NULL , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " socket address " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szSocketAddress ) , NULL , NULL } ,
{ " copy " , P_STRING , P_LOCAL , LOCAL_VAR ( szCopy ) , handle_copy , NULL } ,
{ " include " , P_STRING , P_LOCAL , LOCAL_VAR ( szInclude ) , handle_include , NULL } ,
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:33 +03:00
{ " available " , P_BOOL , P_LOCAL , LOCAL_VAR ( bAvailable ) , NULL , NULL } ,
{ " volume " , P_STRING , P_LOCAL , LOCAL_VAR ( volume ) , NULL , NULL } ,
{ " fstype " , P_STRING , P_LOCAL , LOCAL_VAR ( fstype ) , NULL , NULL } ,
2004-01-29 12:47:39 +03:00
2007-12-09 01:32:33 +03:00
{ " panic action " , P_STRING , P_GLOBAL , GLOBAL_VAR ( panic_action ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
{ " msdfs root " , P_BOOL , P_LOCAL , LOCAL_VAR ( bMSDfsRoot ) , NULL , NULL } ,
{ " host msdfs " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bHostMSDfs ) , NULL , NULL } ,
{ " winbind separator " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWinbindSeparator ) , NULL , NULL } ,
{ " winbindd socket directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWinbinddSocketDirectory ) , NULL , NULL } ,
2008-06-28 16:02:19 +04:00
{ " winbindd privileged socket directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szWinbinddPrivilegedSocketDirectory ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ " winbind sealed pipes " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bWinbindSealedPipes ) , NULL , NULL } ,
{ " template shell " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szTemplateShell ) , NULL , NULL } ,
{ " template homedir " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szTemplateHomedir ) , NULL , NULL } ,
2008-02-17 22:25:13 +03:00
{ " idmap trusted only " , P_BOOL , P_GLOBAL , GLOBAL_VAR ( bIdmapTrustedOnly ) , NULL , NULL } ,
2003-08-13 05:53:07 +04:00
2008-05-29 09:20:58 +04:00
{ " ntp signd socket directory " , P_STRING , P_GLOBAL , GLOBAL_VAR ( szNTPSignDSocketDirectory ) , NULL , NULL } ,
2007-12-09 01:32:33 +03:00
{ NULL , P_BOOL , P_NONE , 0 , NULL , NULL }
2003-08-13 05:53:07 +04:00
} ;
2008-02-28 22:04:58 +03:00
2007-12-09 01:32:33 +03:00
/* local variables */
struct loadparm_context {
2007-12-09 01:32:37 +03:00
const char * szConfigFile ;
2007-12-09 01:32:33 +03:00
struct loadparm_global * globals ;
struct loadparm_service * * services ;
2008-02-28 22:04:58 +03:00
struct loadparm_service * sDefault ;
2007-12-09 01:32:33 +03:00
int iNumServices ;
struct loadparm_service * currentService ;
bool bInGlobalSection ;
struct file_lists {
struct file_lists * next ;
char * name ;
char * subfname ;
time_t modtime ;
} * file_lists ;
unsigned int flags [ NUMPARAMETERS ] ;
2007-12-14 00:46:09 +03:00
struct smb_iconv_convenience * iconv_convenience ;
2007-12-09 01:32:33 +03:00
} ;
2008-02-28 22:04:58 +03:00
struct loadparm_service * lp_default_service ( struct loadparm_context * lp_ctx )
{
return lp_ctx - > sDefault ;
}
2005-08-05 19:30:33 +04:00
/*
return the parameter table
*/
struct parm_struct * lp_parm_table ( void )
{
return parm_table ;
}
2007-12-09 01:32:33 +03:00
/**
* Convenience routine to grab string parameters into temporary memory
2008-02-10 15:01:20 +03:00
* and run standard_sub_basic on them .
2007-12-09 01:32:33 +03:00
*
* The buffers can be written to by
* callers without affecting the source string .
*/
2003-08-13 05:53:07 +04:00
2004-06-14 03:50:55 +04:00
static const char * lp_string ( const char * s )
2003-08-13 05:53:07 +04:00
{
2003-09-18 05:34:59 +04:00
#if 0 /* until REWRITE done to make thread-safe */
2003-08-13 05:53:07 +04:00
size_t len = s ? strlen ( s ) : 0 ;
char * ret ;
2003-09-18 05:34:59 +04:00
# endif
2003-08-13 05:53:07 +04:00
/* The follow debug is useful for tracking down memory problems
especially if you have an inner loop that is calling a lp_ * ( )
function that returns a string . Perhaps this debug should be
present all the time ? */
#if 0
DEBUG ( 10 , ( " lp_string(%s) \n " , s ) ) ;
# endif
2003-09-18 05:34:59 +04:00
2003-08-13 05:53:07 +04:00
#if 0 /* until REWRITE done to make thread-safe */
if ( ! lp_talloc )
lp_talloc = talloc_init ( " lp_talloc " ) ;
2005-01-27 10:08:20 +03:00
ret = talloc_array ( lp_talloc , char , len + 100 ) ; /* leave room for substitution */
2003-08-13 05:53:07 +04:00
if ( ! ret )
return NULL ;
if ( ! s )
* ret = 0 ;
else
2006-04-28 02:59:20 +04:00
strlcpy ( ret , s , len ) ;
2003-08-13 05:53:07 +04:00
if ( trim_string ( ret , " \" " , " \" " ) ) {
if ( strchr ( ret , ' " ' ) ! = NULL )
2006-04-28 02:59:20 +04:00
strlcpy ( ret , s , len ) ;
2003-08-13 05:53:07 +04:00
}
standard_sub_basic ( ret , len + 100 ) ;
return ( ret ) ;
# endif
return s ;
}
/*
2008-02-10 15:01:20 +03:00
In this section all the functions that are used to access the
parameters from the rest of the program are defined
2003-08-13 05:53:07 +04:00
*/
2007-09-28 05:17:46 +04:00
# define FN_GLOBAL_STRING(fn_name,var_name) \
2007-12-09 01:31:55 +03:00
const char * fn_name ( struct loadparm_context * lp_ctx ) { if ( lp_ctx = = NULL ) return NULL ; return lp_ctx - > globals - > var_name ? lp_string ( lp_ctx - > globals - > var_name ) : " " ; }
2007-09-28 05:17:46 +04:00
# define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
2007-12-09 01:31:55 +03:00
const char * fn_name ( struct loadparm_context * lp_ctx ) { if ( lp_ctx = = NULL ) return NULL ; return lp_ctx - > globals - > var_name ? lp_ctx - > globals - > var_name : " " ; }
2007-09-28 05:17:46 +04:00
# define FN_GLOBAL_LIST(fn_name,var_name) \
2007-12-09 01:31:55 +03:00
const char * * fn_name ( struct loadparm_context * lp_ctx ) { if ( lp_ctx = = NULL ) return NULL ; return lp_ctx - > globals - > var_name ; }
2007-09-28 05:17:46 +04:00
# define FN_GLOBAL_BOOL(fn_name,var_name) \
2007-12-09 01:31:55 +03:00
bool fn_name ( struct loadparm_context * lp_ctx ) { if ( lp_ctx = = NULL ) return false ; return lp_ctx - > globals - > var_name ; }
2006-08-24 12:48:15 +04:00
#if 0 /* unused */
2003-08-13 05:53:07 +04:00
# define FN_GLOBAL_CHAR(fn_name,ptr) \
char fn_name ( void ) { return ( * ( char * ) ( ptr ) ) ; }
2006-08-24 12:48:15 +04:00
# endif
2007-09-28 05:17:46 +04:00
# define FN_GLOBAL_INTEGER(fn_name,var_name) \
2007-12-14 00:46:41 +03:00
int fn_name ( struct loadparm_context * lp_ctx ) { return lp_ctx - > globals - > var_name ; }
2003-08-13 05:53:07 +04:00
# define FN_LOCAL_STRING(fn_name,val) \
2008-02-28 22:04:58 +03:00
const char * fn_name ( struct loadparm_service * service , struct loadparm_service * sDefault ) { return ( lp_string ( ( const char * ) ( ( service ! = NULL & & service - > val ! = NULL ) ? service - > val : sDefault - > val ) ) ) ; }
2003-08-13 05:53:07 +04:00
# define FN_LOCAL_LIST(fn_name,val) \
2008-02-28 22:04:58 +03:00
const char * * fn_name ( struct loadparm_service * service , struct loadparm_service * sDefault ) { return ( const char * * ) ( service ! = NULL & & service - > val ! = NULL ? service - > val : sDefault - > val ) ; }
2003-08-13 05:53:07 +04:00
# define FN_LOCAL_BOOL(fn_name,val) \
2008-02-28 22:04:58 +03:00
bool fn_name ( struct loadparm_service * service , struct loadparm_service * sDefault ) { return ( ( service ! = NULL ) ? service - > val : sDefault - > val ) ; }
2003-08-13 05:53:07 +04:00
# define FN_LOCAL_INTEGER(fn_name,val) \
2008-02-28 22:04:58 +03:00
int fn_name ( struct loadparm_service * service , struct loadparm_service * sDefault ) { return ( ( service ! = NULL ) ? service - > val : sDefault - > val ) ; }
2007-09-08 05:29:52 +04:00
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_server_role , server_role )
_PUBLIC_ FN_GLOBAL_LIST ( lp_smb_ports , smb_ports )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_nbt_port , nbt_port )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_dgram_port , dgram_port )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_cldap_port , cldap_port )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_krb5_port , krb5_port )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_kpasswd_port , kpasswd_port )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_web_port , web_port )
_PUBLIC_ FN_GLOBAL_STRING ( lp_swat_directory , swat_directory )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_tls_enabled , tls_enabled )
_PUBLIC_ FN_GLOBAL_STRING ( lp_tls_keyfile , tls_keyfile )
_PUBLIC_ FN_GLOBAL_STRING ( lp_tls_certfile , tls_certfile )
_PUBLIC_ FN_GLOBAL_STRING ( lp_tls_cafile , tls_cafile )
_PUBLIC_ FN_GLOBAL_STRING ( lp_tls_crlfile , tls_crlfile )
_PUBLIC_ FN_GLOBAL_STRING ( lp_tls_dhpfile , tls_dhpfile )
_PUBLIC_ FN_GLOBAL_STRING ( lp_share_backend , szShareBackend )
_PUBLIC_ FN_GLOBAL_STRING ( lp_sam_url , szSAM_URL )
2008-02-17 22:25:13 +03:00
_PUBLIC_ FN_GLOBAL_STRING ( lp_idmap_url , szIDMAP_URL )
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_STRING ( lp_secrets_url , szSECRETS_URL )
_PUBLIC_ FN_GLOBAL_STRING ( lp_spoolss_url , szSPOOLSS_URL )
_PUBLIC_ FN_GLOBAL_STRING ( lp_wins_config_url , szWINS_CONFIG_URL )
_PUBLIC_ FN_GLOBAL_STRING ( lp_wins_url , szWINS_URL )
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_winbind_separator , szWinbindSeparator )
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_winbindd_socket_directory , szWinbinddSocketDirectory )
2008-06-28 16:02:19 +04:00
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_winbindd_privileged_socket_directory , szWinbinddPrivilegedSocketDirectory )
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_template_shell , szTemplateShell )
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_template_homedir , szTemplateHomedir )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_winbind_sealed_pipes , bWinbindSealedPipes )
2008-02-17 22:25:13 +03:00
_PUBLIC_ FN_GLOBAL_BOOL ( lp_idmap_trusted_only , bIdmapTrustedOnly )
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_STRING ( lp_private_dir , szPrivateDir )
_PUBLIC_ FN_GLOBAL_STRING ( lp_serverstring , szServerString )
_PUBLIC_ FN_GLOBAL_STRING ( lp_lockdir , szLockDir )
_PUBLIC_ FN_GLOBAL_STRING ( lp_modulesdir , szModulesDir )
_PUBLIC_ FN_GLOBAL_STRING ( lp_setupdir , szSetupDir )
_PUBLIC_ FN_GLOBAL_STRING ( lp_ncalrpc_dir , ncalrpc_dir )
2007-10-02 03:26:37 +04:00
_PUBLIC_ FN_GLOBAL_STRING ( lp_dos_charset , dos_charset )
_PUBLIC_ FN_GLOBAL_STRING ( lp_unix_charset , unix_charset )
_PUBLIC_ FN_GLOBAL_STRING ( lp_display_charset , display_charset )
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_STRING ( lp_piddir , szPidDir )
_PUBLIC_ FN_GLOBAL_LIST ( lp_dcerpc_endpoint_servers , dcerpc_ep_servers )
_PUBLIC_ FN_GLOBAL_LIST ( lp_server_services , server_services )
_PUBLIC_ FN_GLOBAL_STRING ( lp_ntptr_providor , ntptr_providor )
_PUBLIC_ FN_GLOBAL_STRING ( lp_auto_services , szAutoServices )
_PUBLIC_ FN_GLOBAL_STRING ( lp_passwd_chat , szPasswdChat )
_PUBLIC_ FN_GLOBAL_LIST ( lp_passwordserver , szPasswordServers )
_PUBLIC_ FN_GLOBAL_LIST ( lp_name_resolve_order , szNameResolveOrder )
_PUBLIC_ FN_GLOBAL_STRING ( lp_realm , szRealm )
_PUBLIC_ FN_GLOBAL_STRING ( lp_socket_options , socket_options )
_PUBLIC_ FN_GLOBAL_STRING ( lp_workgroup , szWorkgroup )
_PUBLIC_ FN_GLOBAL_STRING ( lp_netbios_name , szNetbiosName )
_PUBLIC_ FN_GLOBAL_STRING ( lp_netbios_scope , szNetbiosScope )
_PUBLIC_ FN_GLOBAL_LIST ( lp_wins_server_list , szWINSservers )
_PUBLIC_ FN_GLOBAL_LIST ( lp_interfaces , szInterfaces )
_PUBLIC_ FN_GLOBAL_STRING ( lp_socket_address , szSocketAddress )
_PUBLIC_ FN_GLOBAL_LIST ( lp_netbios_aliases , szNetbiosAliases )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_disable_netbios , bDisableNetbios )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_wins_support , bWINSsupport )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_wins_dns_proxy , bWINSdnsProxy )
_PUBLIC_ FN_GLOBAL_STRING ( lp_wins_hook , szWINSHook )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_local_master , bLocalMaster )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_readraw , bReadRaw )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_large_readwrite , bLargeReadwrite )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_writeraw , bWriteRaw )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_null_passwords , bNullPasswords )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_obey_pam_restrictions , bObeyPamRestrictions )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_encrypted_passwords , bEncryptPasswords )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_time_server , bTimeServer )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_bind_interfaces_only , bBindInterfacesOnly )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_unicode , bUnicode )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_nt_status_support , bNTStatusSupport )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_lanman_auth , bLanmanAuth )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_ntlm_auth , bNTLMAuth )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_client_plaintext_auth , bClientPlaintextAuth )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_client_lanman_auth , bClientLanManAuth )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_client_ntlmv2_auth , bClientNTLMv2Auth )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_client_use_spnego_principal , client_use_spnego_principal )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_host_msdfs , bHostMSDfs )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_unix_extensions , bUnixExtensions )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_use_spnego , bUseSpnego )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_rpc_big_endian , bRpcBigEndian )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_max_wins_ttl , max_wins_ttl )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_min_wins_ttl , min_wins_ttl )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_maxmux , max_mux )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_max_xmit , max_xmit )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_passwordlevel , pwordlevel )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_srv_maxprotocol , srv_maxprotocol )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_srv_minprotocol , srv_minprotocol )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_cli_maxprotocol , cli_maxprotocol )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_cli_minprotocol , cli_minprotocol )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_security , security )
_PUBLIC_ FN_GLOBAL_BOOL ( lp_paranoid_server_security , paranoid_server_security )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_announce_as , announce_as )
2008-02-28 22:04:58 +03:00
const char * lp_servicename ( const struct loadparm_service * service )
{
return lp_string ( ( const char * ) service - > szService ) ;
}
2006-03-07 19:51:56 +03:00
_PUBLIC_ FN_LOCAL_STRING ( lp_pathname , szPath )
2003-08-13 05:53:07 +04:00
static FN_LOCAL_STRING ( _lp_printername , szPrintername )
2006-03-07 19:51:56 +03:00
_PUBLIC_ FN_LOCAL_LIST ( lp_hostsallow , szHostsallow )
_PUBLIC_ FN_LOCAL_LIST ( lp_hostsdeny , szHostsdeny )
_PUBLIC_ FN_LOCAL_STRING ( lp_comment , comment )
_PUBLIC_ FN_LOCAL_STRING ( lp_fstype , fstype )
2003-08-13 05:53:07 +04:00
static FN_LOCAL_STRING ( lp_volume , volume )
2006-03-07 19:51:56 +03:00
_PUBLIC_ FN_LOCAL_LIST ( lp_ntvfs_handler , ntvfs_handler )
_PUBLIC_ FN_LOCAL_BOOL ( lp_msdfs_root , bMSDfsRoot )
_PUBLIC_ FN_LOCAL_BOOL ( lp_browseable , bBrowseable )
_PUBLIC_ FN_LOCAL_BOOL ( lp_readonly , bRead_only )
_PUBLIC_ FN_LOCAL_BOOL ( lp_print_ok , bPrint_ok )
_PUBLIC_ FN_LOCAL_BOOL ( lp_map_hidden , bMap_hidden )
_PUBLIC_ FN_LOCAL_BOOL ( lp_map_archive , bMap_archive )
_PUBLIC_ FN_LOCAL_BOOL ( lp_strict_locking , bStrictLocking )
2008-03-27 12:32:02 +03:00
_PUBLIC_ FN_LOCAL_BOOL ( lp_oplocks , bOplocks )
2006-03-07 19:51:56 +03:00
_PUBLIC_ FN_LOCAL_BOOL ( lp_strict_sync , bStrictSync )
_PUBLIC_ FN_LOCAL_BOOL ( lp_ci_filesystem , bCIFileSystem )
_PUBLIC_ FN_LOCAL_BOOL ( lp_map_system , bMap_system )
_PUBLIC_ FN_LOCAL_INTEGER ( lp_max_connections , iMaxConnections )
_PUBLIC_ FN_LOCAL_INTEGER ( lp_csc_policy , iCSCPolicy )
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
_PUBLIC_ FN_LOCAL_INTEGER ( lp_create_mask , iCreate_mask )
_PUBLIC_ FN_LOCAL_INTEGER ( lp_force_create_mode , iCreate_force_mode )
_PUBLIC_ FN_LOCAL_INTEGER ( lp_dir_mask , iDir_mask )
_PUBLIC_ FN_LOCAL_INTEGER ( lp_force_dir_mode , iDir_force_mode )
2007-09-28 05:17:46 +04:00
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_server_signing , server_signing )
_PUBLIC_ FN_GLOBAL_INTEGER ( lp_client_signing , client_signing )
2003-08-13 05:53:07 +04:00
2008-05-29 09:20:58 +04:00
_PUBLIC_ FN_GLOBAL_CONST_STRING ( lp_ntp_signd_socket_directory , szNTPSignDSocketDirectory )
2003-08-13 05:53:07 +04:00
/* local prototypes */
static int map_parameter ( const char * pszParmName ) ;
2007-09-09 00:03:19 +04:00
static struct loadparm_service * getservicebyname ( struct loadparm_context * lp_ctx ,
const char * pszServiceName ) ;
static void copy_service ( struct loadparm_service * pserviceDest ,
2008-02-10 15:01:20 +03:00
struct loadparm_service * pserviceSource ,
2007-09-09 00:03:19 +04:00
int * pcopymapDest ) ;
static bool service_ok ( struct loadparm_service * service ) ;
2007-09-08 04:07:50 +04:00
static bool do_section ( const char * pszSectionName , void * ) ;
2007-09-09 00:03:19 +04:00
static void init_copymap ( struct loadparm_service * pservice ) ;
2003-08-13 05:53:07 +04:00
/* This is a helper function for parametrical options support. */
/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
/* Actual parametrical functions are quite simple */
2008-02-10 15:01:20 +03:00
const char * lp_get_parametric ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service ,
2007-09-09 00:03:19 +04:00
const char * type , const char * option )
2003-08-13 05:53:07 +04:00
{
char * vfskey ;
struct param_opt * data ;
2007-12-14 00:46:30 +03:00
if ( lp_ctx = = NULL )
return NULL ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:31:55 +03:00
data = ( service = = NULL ? lp_ctx - > globals - > param_opt : service - > param_opt ) ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
asprintf ( & vfskey , " %s:%s " , type , option ) ;
strlower ( vfskey ) ;
while ( data ) {
if ( strcmp ( data - > key , vfskey ) = = 0 ) {
free ( vfskey ) ;
return data - > value ;
}
data = data - > next ;
}
2007-09-08 20:46:30 +04:00
if ( service ! = NULL ) {
2003-08-13 05:53:07 +04:00
/* Try to fetch the same option but from globals */
2007-12-09 01:31:55 +03:00
/* but only if we are not already working with globals */
2008-02-10 15:01:20 +03:00
for ( data = lp_ctx - > globals - > param_opt ; data ;
2007-09-08 05:29:52 +04:00
data = data - > next ) {
2003-08-13 05:53:07 +04:00
if ( strcmp ( data - > key , vfskey ) = = 0 ) {
free ( vfskey ) ;
return data - > value ;
}
}
}
free ( vfskey ) ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
return NULL ;
}
2007-12-09 01:32:33 +03:00
/**
* convenience routine to return int parameters .
*/
2003-08-13 05:53:07 +04:00
static int lp_int ( const char * s )
{
if ( ! s ) {
DEBUG ( 0 , ( " lp_int(%s): is called with NULL! \n " , s ) ) ;
2007-09-08 03:37:00 +04:00
return - 1 ;
2003-08-13 05:53:07 +04:00
}
2008-02-10 15:01:20 +03:00
return strtol ( s , NULL , 0 ) ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* convenience routine to return unsigned long parameters .
*/
2003-08-13 05:53:07 +04:00
static int lp_ulong ( const char * s )
{
if ( ! s ) {
DEBUG ( 0 , ( " lp_int(%s): is called with NULL! \n " , s ) ) ;
2007-09-08 03:37:00 +04:00
return - 1 ;
2003-08-13 05:53:07 +04:00
}
2005-06-21 08:24:49 +04:00
return strtoul ( s , NULL , 0 ) ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* convenience routine to return unsigned long parameters .
*/
2007-06-18 00:02:56 +04:00
static double lp_double ( const char * s )
{
if ( ! s ) {
DEBUG ( 0 , ( " lp_double(%s): is called with NULL! \n " , s ) ) ;
2007-09-08 03:37:00 +04:00
return - 1 ;
2007-06-18 00:02:56 +04:00
}
return strtod ( s , NULL ) ;
}
2007-12-09 01:32:33 +03:00
/**
* convenience routine to return boolean parameters .
*/
2007-09-08 05:29:52 +04:00
static bool lp_bool ( const char * s )
2003-08-13 05:53:07 +04:00
{
2007-09-08 05:29:52 +04:00
bool ret = false ;
2003-08-13 05:53:07 +04:00
if ( ! s ) {
DEBUG ( 0 , ( " lp_bool(%s): is called with NULL! \n " , s ) ) ;
2007-09-08 05:29:52 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
2008-02-10 15:01:20 +03:00
2006-01-28 15:15:24 +03:00
if ( ! set_boolean ( s , & ret ) ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 , ( " lp_bool(%s): value is not boolean! \n " , s ) ) ;
2007-09-08 05:29:52 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
return ret ;
}
2007-12-14 00:46:09 +03:00
/**
* Return parametric option from a given service . Type is a part of option before ' : '
* Parametric option has following syntax : ' Type : option = value '
2008-02-10 15:01:20 +03:00
* Returned value is allocated in ' lp_talloc ' context
2007-12-14 00:46:09 +03:00
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
const char * lp_parm_string ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-08 20:46:30 +04:00
const char * option )
2003-08-13 05:53:07 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2004-12-31 11:43:34 +03:00
2003-08-13 05:53:07 +04:00
if ( value )
return lp_string ( value ) ;
return NULL ;
}
2007-12-14 00:46:09 +03:00
/**
* Return parametric option from a given service . Type is a part of option before ' : '
* Parametric option has following syntax : ' Type : option = value '
* Returned value is allocated in ' lp_talloc ' context
*/
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:18 +03:00
const char * * lp_parm_string_list ( TALLOC_CTX * mem_ctx ,
2008-02-10 15:01:20 +03:00
struct loadparm_context * lp_ctx ,
struct loadparm_service * service ,
const char * type ,
2007-09-08 20:46:30 +04:00
const char * option , const char * separator )
2003-08-13 05:53:07 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:18 +03:00
if ( value ! = NULL )
return str_list_make ( mem_ctx , value , separator ) ;
2003-08-13 05:53:07 +04:00
return NULL ;
}
2007-12-14 00:46:09 +03:00
/**
* Return parametric option from a given service . Type is a part of option before ' : '
* Parametric option has following syntax : ' Type : option = value '
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
int lp_parm_int ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-09 00:03:19 +04:00
const char * option , int default_v )
2003-08-13 05:53:07 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
if ( value )
return lp_int ( value ) ;
2004-12-31 04:03:57 +03:00
return default_v ;
2003-08-13 05:53:07 +04:00
}
2007-12-14 00:46:09 +03:00
/**
* Return parametric option from a given service . Type is a part of
2006-04-24 04:38:53 +04:00
* option before ' : ' .
* Parametric option has following syntax : ' Type : option = value ' .
*/
2008-02-10 15:01:20 +03:00
int lp_parm_bytes ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-08 20:46:30 +04:00
const char * option , int default_v )
2006-04-24 04:38:53 +04:00
{
uint64_t bval ;
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2006-04-24 04:38:53 +04:00
if ( value & & conv_str_size ( value , & bval ) ) {
if ( bval < = INT_MAX ) {
return ( int ) bval ;
}
}
return default_v ;
}
2007-12-14 00:46:09 +03:00
/**
2008-02-10 15:01:20 +03:00
* Return parametric option from a given service .
2007-12-14 00:46:09 +03:00
* Type is a part of option before ' : '
* Parametric option has following syntax : ' Type : option = value '
*/
2008-02-10 15:01:20 +03:00
unsigned long lp_parm_ulong ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-08 20:46:30 +04:00
const char * option , unsigned long default_v )
2003-08-13 05:53:07 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
if ( value )
return lp_ulong ( value ) ;
2004-12-31 04:03:57 +03:00
return default_v ;
2003-08-13 05:53:07 +04:00
}
2007-06-18 00:02:56 +04:00
2008-02-10 15:01:20 +03:00
double lp_parm_double ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-08 20:46:30 +04:00
const char * option , double default_v )
2007-06-18 00:02:56 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:13 +03:00
if ( value ! = NULL )
2007-06-18 00:02:56 +04:00
return lp_double ( value ) ;
return default_v ;
}
2007-12-14 00:46:09 +03:00
/**
* Return parametric option from a given service . Type is a part of option before ' : '
* Parametric option has following syntax : ' Type : option = value '
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
bool lp_parm_bool ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , const char * type ,
2007-09-08 20:46:30 +04:00
const char * option , bool default_v )
2003-08-13 05:53:07 +04:00
{
2007-09-29 22:00:19 +04:00
const char * value = lp_get_parametric ( lp_ctx , service , type , option ) ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:13 +03:00
if ( value ! = NULL )
2003-08-13 05:53:07 +04:00
return lp_bool ( value ) ;
return default_v ;
}
2007-12-09 01:32:33 +03:00
/**
* Initialise a service to the defaults .
*/
2003-08-13 05:53:07 +04:00
2008-02-28 22:04:58 +03:00
static struct loadparm_service * init_service ( TALLOC_CTX * mem_ctx , struct loadparm_service * sDefault )
2003-08-13 05:53:07 +04:00
{
2008-02-10 15:01:20 +03:00
struct loadparm_service * pservice =
2007-09-09 00:03:19 +04:00
talloc_zero ( mem_ctx , struct loadparm_service ) ;
2008-02-28 22:04:58 +03:00
copy_service ( pservice , sDefault , NULL ) ;
2007-09-08 04:07:50 +04:00
return pservice ;
2003-08-13 05:53:07 +04:00
}
2007-09-09 23:34:30 +04:00
/**
2007-12-14 00:46:09 +03:00
* Set a string value , deallocating any existing space , and allocing the space
* for the string
*/
2007-09-09 23:34:30 +04:00
static bool string_set ( TALLOC_CTX * mem_ctx , char * * dest , const char * src )
{
talloc_free ( * dest ) ;
2008-02-10 15:01:20 +03:00
if ( src = = NULL )
2007-09-09 23:34:30 +04:00
src = " " ;
* dest = talloc_strdup ( mem_ctx , src ) ;
if ( ( * dest ) = = NULL ) {
DEBUG ( 0 , ( " Out of memory in string_init \n " ) ) ;
return false ;
}
return true ;
}
2007-12-09 01:32:33 +03:00
/**
2008-02-10 15:01:20 +03:00
* Add a new service to the services array initialising it with the given
* service .
2007-12-09 01:32:33 +03:00
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
struct loadparm_service * lp_add_service ( struct loadparm_context * lp_ctx ,
const struct loadparm_service * pservice ,
2007-09-08 23:16:08 +04:00
const char * name )
2003-08-13 05:53:07 +04:00
{
int i ;
2007-09-09 00:03:19 +04:00
struct loadparm_service tservice ;
2007-09-08 23:16:08 +04:00
int num_to_alloc = lp_ctx - > iNumServices + 1 ;
2003-08-13 05:53:07 +04:00
struct param_opt * data , * pdata ;
tservice = * pservice ;
/* it might already exist */
if ( name ) {
2008-02-10 15:01:20 +03:00
struct loadparm_service * service = getservicebyname ( lp_ctx ,
2007-09-09 00:03:19 +04:00
name ) ;
2007-09-08 18:12:45 +04:00
if ( service ! = NULL ) {
2003-08-13 05:53:07 +04:00
/* Clean all parametric options for service */
/* They will be added during parsing again */
2007-09-08 18:12:45 +04:00
data = service - > param_opt ;
2003-08-13 05:53:07 +04:00
while ( data ) {
pdata = data - > next ;
2007-09-08 04:38:22 +04:00
talloc_free ( data ) ;
2003-08-13 05:53:07 +04:00
data = pdata ;
}
2007-09-08 18:12:45 +04:00
service - > param_opt = NULL ;
return service ;
2003-08-13 05:53:07 +04:00
}
}
/* find an invalid one */
2007-09-08 23:16:08 +04:00
for ( i = 0 ; i < lp_ctx - > iNumServices ; i + + )
2007-12-09 01:32:01 +03:00
if ( lp_ctx - > services [ i ] = = NULL )
2003-08-13 05:53:07 +04:00
break ;
/* if not, then create one */
2007-09-08 23:16:08 +04:00
if ( i = = lp_ctx - > iNumServices ) {
2007-09-09 00:03:19 +04:00
struct loadparm_service * * tsp ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:01 +03:00
tsp = talloc_realloc ( lp_ctx , lp_ctx - > services , struct loadparm_service * , num_to_alloc ) ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
if ( ! tsp ) {
2007-12-09 01:32:01 +03:00
DEBUG ( 0 , ( " lp_add_service: failed to enlarge services! \n " ) ) ;
2007-09-08 18:12:45 +04:00
return NULL ;
2007-12-09 01:32:01 +03:00
} else {
lp_ctx - > services = tsp ;
lp_ctx - > services [ lp_ctx - > iNumServices ] = NULL ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 23:16:08 +04:00
lp_ctx - > iNumServices + + ;
2008-02-10 15:01:20 +03:00
}
2003-08-13 05:53:07 +04:00
2008-02-28 22:04:58 +03:00
lp_ctx - > services [ i ] = init_service ( lp_ctx - > services , lp_ctx - > sDefault ) ;
2007-12-09 01:32:01 +03:00
if ( lp_ctx - > services [ i ] = = NULL ) {
2007-11-21 16:49:27 +03:00
DEBUG ( 0 , ( " lp_add_service: out of memory! \n " ) ) ;
2007-09-08 18:12:45 +04:00
return NULL ;
2007-09-08 04:07:50 +04:00
}
2007-12-09 01:32:01 +03:00
copy_service ( lp_ctx - > services [ i ] , & tservice , NULL ) ;
2007-09-08 04:07:50 +04:00
if ( name ! = NULL )
2007-12-09 01:32:01 +03:00
string_set ( lp_ctx - > services [ i ] , & lp_ctx - > services [ i ] - > szService , name ) ;
return lp_ctx - > services [ i ] ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
2008-02-10 15:01:20 +03:00
* Add a new home service , with the specified home directory , defaults coming
2007-12-09 01:32:33 +03:00
* from service ifrom .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
bool lp_add_home ( struct loadparm_context * lp_ctx ,
const char * pszHomename ,
2007-09-09 00:03:19 +04:00
struct loadparm_service * default_service ,
2003-08-13 05:53:07 +04:00
const char * user , const char * pszHomedir )
{
2007-09-09 00:03:19 +04:00
struct loadparm_service * service ;
2003-08-13 05:53:07 +04:00
2007-11-21 16:49:27 +03:00
service = lp_add_service ( lp_ctx , default_service , pszHomename ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 18:12:45 +04:00
if ( service = = NULL )
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
2007-09-08 20:46:30 +04:00
if ( ! ( * ( default_service - > szPath ) )
2008-02-28 22:04:58 +03:00
| | strequal ( default_service - > szPath , lp_ctx - > sDefault - > szPath ) ) {
2007-09-24 22:47:50 +04:00
service - > szPath = talloc_strdup ( service , pszHomedir ) ;
2003-08-13 05:53:07 +04:00
} else {
2008-02-28 22:04:58 +03:00
service - > szPath = string_sub_talloc ( service , lp_pathname ( default_service , lp_ctx - > sDefault ) , " %H " , pszHomedir ) ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 18:12:45 +04:00
if ( ! ( * ( service - > comment ) ) ) {
service - > comment = talloc_asprintf ( service , " Home directory of %s " , user ) ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 20:46:30 +04:00
service - > bAvailable = default_service - > bAvailable ;
service - > bBrowseable = default_service - > bBrowseable ;
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
DEBUG ( 3 , ( " adding home's share [%s] for user '%s' at '%s' \n " ,
2007-09-24 22:47:50 +04:00
pszHomename , user , service - > szPath ) ) ;
2008-02-10 15:01:20 +03:00
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Add the IPC service .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
static bool lp_add_hidden ( struct loadparm_context * lp_ctx , const char * name ,
2007-09-08 23:16:08 +04:00
const char * fstype )
2003-08-13 05:53:07 +04:00
{
2008-02-28 22:04:58 +03:00
struct loadparm_service * service = lp_add_service ( lp_ctx , lp_ctx - > sDefault , name ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 18:12:45 +04:00
if ( service = = NULL )
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
2007-09-08 05:29:52 +04:00
string_set ( service , & service - > szPath , tmpdir ( ) ) ;
2007-09-08 04:07:50 +04:00
2008-02-10 15:01:20 +03:00
service - > comment = talloc_asprintf ( service , " %s Service (%s) " ,
2007-12-09 01:31:55 +03:00
fstype , lp_ctx - > globals - > szServerString ) ;
2007-09-08 05:29:52 +04:00
string_set ( service , & service - > fstype , fstype ) ;
service - > iMaxConnections = - 1 ;
service - > bAvailable = true ;
service - > bRead_only = true ;
service - > bPrint_ok = false ;
service - > bBrowseable = false ;
2003-08-13 05:53:07 +04:00
2004-12-31 10:35:14 +03:00
if ( strcasecmp ( fstype , " IPC " ) = = 0 ) {
2008-02-10 15:01:20 +03:00
lp_do_service_parameter ( lp_ctx , service , " ntvfs handler " ,
2007-09-09 00:49:43 +04:00
" default " ) ;
2004-12-31 10:35:14 +03:00
}
2004-10-30 15:07:28 +04:00
2004-12-31 10:35:14 +03:00
DEBUG ( 3 , ( " adding hidden service %s \n " , name ) ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Add a new printer service , with defaults coming from service iFrom .
*/
2003-08-13 05:53:07 +04:00
2007-09-08 23:16:08 +04:00
bool lp_add_printer ( struct loadparm_context * lp_ctx ,
2008-02-10 15:01:20 +03:00
const char * pszPrintername ,
2007-09-09 00:03:19 +04:00
struct loadparm_service * default_service )
2003-08-13 05:53:07 +04:00
{
const char * comment = " From Printcap " ;
2007-09-09 00:03:19 +04:00
struct loadparm_service * service ;
2007-11-21 16:49:27 +03:00
service = lp_add_service ( lp_ctx , default_service , pszPrintername ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 18:12:45 +04:00
if ( service = = NULL )
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
/* note that we do NOT default the availability flag to True - */
/* we take it from the default service passed. This allows all */
/* dynamic printers to be disabled by disabling the [printers] */
/* entry (if/when the 'available' keyword is implemented!). */
/* the printer name is set to the service name. */
2007-09-08 18:12:45 +04:00
string_set ( service , & service - > szPrintername , pszPrintername ) ;
string_set ( service , & service - > comment , comment ) ;
2007-12-09 01:32:01 +03:00
service - > bBrowseable = default_service - > bBrowseable ;
2003-08-13 05:53:07 +04:00
/* Printers cannot be read_only. */
2007-09-08 18:12:45 +04:00
service - > bRead_only = false ;
2003-08-13 05:53:07 +04:00
/* Printer services must be printable. */
2007-09-08 18:12:45 +04:00
service - > bPrint_ok = true ;
2003-08-13 05:53:07 +04:00
DEBUG ( 3 , ( " adding printer service %s \n " , pszPrintername ) ) ;
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:23 +03:00
/**
2008-02-10 15:01:20 +03:00
* Map a parameter ' s string representation to something we can use .
2007-12-09 01:32:23 +03:00
* Returns False if the parameter string is not recognised , else TRUE .
*/
2003-08-13 05:53:07 +04:00
static int map_parameter ( const char * pszParmName )
{
int iIndex ;
if ( * pszParmName = = ' - ' )
2007-09-08 03:37:00 +04:00
return - 1 ;
2003-08-13 05:53:07 +04:00
for ( iIndex = 0 ; parm_table [ iIndex ] . label ; iIndex + + )
if ( strwicmp ( parm_table [ iIndex ] . label , pszParmName ) = = 0 )
2007-09-08 03:37:00 +04:00
return iIndex ;
2003-08-13 05:53:07 +04:00
/* Warn only if it isn't parametric option */
if ( strchr ( pszParmName , ' : ' ) = = NULL )
DEBUG ( 0 , ( " Unknown parameter encountered: \" %s \" \n " , pszParmName ) ) ;
/* We do return 'fail' for parametric options as well because they are
stored in different storage
*/
2007-09-08 03:37:00 +04:00
return - 1 ;
2003-08-13 05:53:07 +04:00
}
2005-05-27 11:14:01 +04:00
2007-12-09 01:32:23 +03:00
/**
2005-05-27 11:14:01 +04:00
return the parameter structure for a parameter
*/
struct parm_struct * lp_parm_struct ( const char * name )
{
int parmnum = map_parameter ( name ) ;
if ( parmnum = = - 1 ) return NULL ;
return & parm_table [ parmnum ] ;
}
2007-12-09 01:32:23 +03:00
/**
2005-05-27 11:14:01 +04:00
return the parameter pointer for a parameter
*/
2007-12-07 18:04:22 +03:00
void * lp_parm_ptr ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service , struct parm_struct * parm )
2005-05-27 11:14:01 +04:00
{
2007-12-07 18:04:22 +03:00
if ( service = = NULL ) {
if ( parm - > class = = P_LOCAL )
2008-02-28 22:04:58 +03:00
return ( ( char * ) lp_ctx - > sDefault ) + parm - > offset ;
2007-12-09 01:31:41 +03:00
else if ( parm - > class = = P_GLOBAL )
2007-12-09 01:31:55 +03:00
return ( ( char * ) lp_ctx - > globals ) + parm - > offset ;
2007-12-09 01:31:41 +03:00
else return NULL ;
} else {
return ( ( char * ) service ) + parm - > offset ;
2007-12-07 18:04:22 +03:00
}
2005-05-27 11:14:01 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Find a service by name . Otherwise works like get_service .
*/
2003-08-13 05:53:07 +04:00
2007-09-09 00:03:19 +04:00
static struct loadparm_service * getservicebyname ( struct loadparm_context * lp_ctx ,
const char * pszServiceName )
2003-08-13 05:53:07 +04:00
{
int iService ;
2007-09-09 00:03:19 +04:00
for ( iService = lp_ctx - > iNumServices - 1 ; iService > = 0 ; iService - - )
2007-12-09 01:32:01 +03:00
if ( lp_ctx - > services [ iService ] ! = NULL & &
strwicmp ( lp_ctx - > services [ iService ] - > szService , pszServiceName ) = = 0 ) {
return lp_ctx - > services [ iService ] ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 18:12:45 +04:00
return NULL ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Copy a service structure to another .
* If pcopymapDest is NULL then copy all fields
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
static void copy_service ( struct loadparm_service * pserviceDest ,
struct loadparm_service * pserviceSource ,
2007-09-08 03:37:00 +04:00
int * pcopymapDest )
2003-08-13 05:53:07 +04:00
{
int i ;
2007-09-08 03:37:00 +04:00
bool bcopyall = ( pcopymapDest = = NULL ) ;
2003-08-13 05:53:07 +04:00
struct param_opt * data , * pdata , * paramo ;
2007-09-08 03:37:00 +04:00
bool not_added ;
2003-08-13 05:53:07 +04:00
for ( i = 0 ; parm_table [ i ] . label ; i + + )
2007-12-07 18:04:22 +03:00
if ( parm_table [ i ] . offset ! = - 1 & & parm_table [ i ] . class = = P_LOCAL & &
2003-08-13 05:53:07 +04:00
( bcopyall | | pcopymapDest [ i ] ) ) {
void * src_ptr =
2007-12-07 18:04:22 +03:00
( ( char * ) pserviceSource ) + parm_table [ i ] . offset ;
2003-08-13 05:53:07 +04:00
void * dest_ptr =
2007-12-07 18:04:22 +03:00
( ( char * ) pserviceDest ) + parm_table [ i ] . offset ;
2003-08-13 05:53:07 +04:00
switch ( parm_table [ i ] . type ) {
case P_BOOL :
2006-05-24 10:36:17 +04:00
* ( int * ) dest_ptr = * ( int * ) src_ptr ;
2003-08-13 05:53:07 +04:00
break ;
case P_INTEGER :
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
case P_OCTAL :
2003-08-13 05:53:07 +04:00
case P_ENUM :
* ( int * ) dest_ptr = * ( int * ) src_ptr ;
break ;
case P_STRING :
2008-02-10 15:01:20 +03:00
string_set ( pserviceDest ,
2007-09-08 17:27:14 +04:00
( char * * ) dest_ptr ,
2003-08-13 05:53:07 +04:00
* ( char * * ) src_ptr ) ;
break ;
case P_USTRING :
2008-02-10 15:01:20 +03:00
string_set ( pserviceDest ,
2007-09-08 17:27:14 +04:00
( char * * ) dest_ptr ,
2003-08-13 05:53:07 +04:00
* ( char * * ) src_ptr ) ;
strupper ( * ( char * * ) dest_ptr ) ;
break ;
case P_LIST :
2007-12-09 01:31:41 +03:00
* ( const char * * * ) dest_ptr = str_list_copy ( pserviceDest ,
2005-02-14 13:08:10 +03:00
* ( const char * * * ) src_ptr ) ;
2003-08-13 05:53:07 +04:00
break ;
default :
break ;
}
}
if ( bcopyall ) {
init_copymap ( pserviceDest ) ;
if ( pserviceSource - > copymap )
memcpy ( ( void * ) pserviceDest - > copymap ,
( void * ) pserviceSource - > copymap ,
2006-04-01 22:25:07 +04:00
sizeof ( int ) * NUMPARAMETERS ) ;
2003-08-13 05:53:07 +04:00
}
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
data = pserviceSource - > param_opt ;
while ( data ) {
2007-09-08 18:12:45 +04:00
not_added = true ;
2003-08-13 05:53:07 +04:00
pdata = pserviceDest - > param_opt ;
/* Traverse destination */
while ( pdata ) {
/* If we already have same option, override it */
if ( strcmp ( pdata - > key , data - > key ) = = 0 ) {
2007-09-08 23:16:08 +04:00
talloc_free ( pdata - > value ) ;
2008-02-10 15:01:20 +03:00
pdata - > value = talloc_reference ( pdata ,
2007-09-08 04:38:22 +04:00
data - > value ) ;
not_added = false ;
2003-08-13 05:53:07 +04:00
break ;
}
pdata = pdata - > next ;
}
if ( not_added ) {
2007-09-08 04:38:22 +04:00
paramo = talloc ( pserviceDest , struct param_opt ) ;
if ( paramo = = NULL )
2005-09-28 23:56:21 +04:00
smb_panic ( " OOM " ) ;
2007-09-08 04:38:22 +04:00
paramo - > key = talloc_reference ( paramo , data - > key ) ;
paramo - > value = talloc_reference ( paramo , data - > value ) ;
2003-08-13 05:53:07 +04:00
DLIST_ADD ( pserviceDest - > param_opt , paramo ) ;
}
data = data - > next ;
}
}
2007-12-09 01:32:23 +03:00
/**
* Check a service for consistency . Return False if the service is in any way
* incomplete or faulty , else True .
*/
2007-09-09 00:03:19 +04:00
static bool service_ok ( struct loadparm_service * service )
2003-08-13 05:53:07 +04:00
{
2007-09-08 05:29:52 +04:00
bool bRetval ;
2003-08-13 05:53:07 +04:00
2007-09-08 05:29:52 +04:00
bRetval = true ;
2007-09-08 18:12:45 +04:00
if ( service - > szService [ 0 ] = = ' \0 ' ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 , ( " The following message indicates an internal error: \n " ) ) ;
DEBUG ( 0 , ( " No service name in service entry. \n " ) ) ;
2007-09-08 05:29:52 +04:00
bRetval = false ;
2003-08-13 05:53:07 +04:00
}
/* The [printers] entry MUST be printable. I'm all for flexibility, but */
/* I can't see why you'd want a non-printable printer service... */
2007-09-08 18:12:45 +04:00
if ( strwicmp ( service - > szService , PRINTERS_NAME ) = = 0 ) {
if ( ! service - > bPrint_ok ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 , ( " WARNING: [%s] service MUST be printable! \n " ,
2007-09-08 18:12:45 +04:00
service - > szService ) ) ;
service - > bPrint_ok = true ;
2003-08-13 05:53:07 +04:00
}
/* [printers] service must also be non-browsable. */
2007-09-08 18:12:45 +04:00
if ( service - > bBrowseable )
service - > bBrowseable = false ;
2003-08-13 05:53:07 +04:00
}
/* If a service is flagged unavailable, log the fact at level 0. */
2007-09-08 18:12:45 +04:00
if ( ! service - > bAvailable )
2003-08-13 05:53:07 +04:00
DEBUG ( 1 , ( " NOTE: Service %s is flagged unavailable. \n " ,
2007-09-08 18:12:45 +04:00
service - > szService ) ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 03:37:00 +04:00
return bRetval ;
2003-08-13 05:53:07 +04:00
}
/*******************************************************************
2008-02-10 15:01:20 +03:00
Keep a linked list of all config files so we know when one has changed
2003-08-13 05:53:07 +04:00
it ' s date and needs to be reloaded .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-10 15:01:20 +03:00
static void add_to_file_list ( struct loadparm_context * lp_ctx ,
2007-09-09 00:49:43 +04:00
const char * fname , const char * subfname )
2003-08-13 05:53:07 +04:00
{
2007-09-09 00:49:43 +04:00
struct file_lists * f = lp_ctx - > file_lists ;
2003-08-13 05:53:07 +04:00
while ( f ) {
if ( f - > name & & ! strcmp ( f - > name , fname ) )
break ;
f = f - > next ;
}
if ( ! f ) {
2007-12-09 01:31:41 +03:00
f = talloc ( lp_ctx , struct file_lists ) ;
2003-08-13 05:53:07 +04:00
if ( ! f )
return ;
2007-09-09 00:49:43 +04:00
f - > next = lp_ctx - > file_lists ;
2007-09-08 05:29:52 +04:00
f - > name = talloc_strdup ( f , fname ) ;
2003-08-13 05:53:07 +04:00
if ( ! f - > name ) {
2007-09-08 05:29:52 +04:00
talloc_free ( f ) ;
2003-08-13 05:53:07 +04:00
return ;
}
2007-09-08 05:29:52 +04:00
f - > subfname = talloc_strdup ( f , subfname ) ;
2003-08-13 05:53:07 +04:00
if ( ! f - > subfname ) {
2007-09-08 05:29:52 +04:00
talloc_free ( f ) ;
2003-08-13 05:53:07 +04:00
return ;
}
2007-09-09 00:49:43 +04:00
lp_ctx - > file_lists = f ;
2003-08-13 05:53:07 +04:00
f - > modtime = file_modtime ( subfname ) ;
} else {
time_t t = file_modtime ( subfname ) ;
if ( t )
f - > modtime = t ;
}
}
/*******************************************************************
Check if a config file has changed date .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-09-09 00:49:43 +04:00
bool lp_file_list_changed ( struct loadparm_context * lp_ctx )
2003-08-13 05:53:07 +04:00
{
2007-09-08 18:12:45 +04:00
struct file_lists * f ;
2003-08-13 05:53:07 +04:00
DEBUG ( 6 , ( " lp_file_list_changed() \n " ) ) ;
2007-09-09 00:49:43 +04:00
for ( f = lp_ctx - > file_lists ; f ! = NULL ; f = f - > next ) {
2007-09-08 03:37:00 +04:00
char * n2 ;
2003-08-13 05:53:07 +04:00
time_t mod_time ;
2007-12-09 01:31:41 +03:00
n2 = standard_sub_basic ( lp_ctx , f - > name ) ;
2003-08-13 05:53:07 +04:00
DEBUGADD ( 6 , ( " file %s -> %s last mod_time: %s \n " ,
f - > name , n2 , ctime ( & f - > modtime ) ) ) ;
mod_time = file_modtime ( n2 ) ;
if ( mod_time & & ( ( f - > modtime ! = mod_time ) | | ( f - > subfname = = NULL ) | | ( strcmp ( n2 , f - > subfname ) ! = 0 ) ) ) {
2007-09-08 18:12:45 +04:00
DEBUGADD ( 6 , ( " file %s modified: %s \n " , n2 ,
2003-08-13 05:53:07 +04:00
ctime ( & mod_time ) ) ) ;
f - > modtime = mod_time ;
2007-09-08 05:29:52 +04:00
talloc_free ( f - > subfname ) ;
f - > subfname = talloc_strdup ( f , n2 ) ;
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
}
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
/***************************************************************************
Handle the include operation .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-10 15:01:20 +03:00
static bool handle_include ( struct loadparm_context * lp_ctx ,
2007-09-09 00:49:43 +04:00
const char * pszParmValue , char * * ptr )
2003-08-13 05:53:07 +04:00
{
2007-12-09 01:31:41 +03:00
char * fname = standard_sub_basic ( lp_ctx , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
2007-09-09 00:49:43 +04:00
add_to_file_list ( lp_ctx , pszParmValue , fname ) ;
2003-08-13 05:53:07 +04:00
2007-12-09 01:31:41 +03:00
string_set ( lp_ctx , ptr , fname ) ;
2003-08-13 05:53:07 +04:00
2005-02-10 09:36:30 +03:00
if ( file_exist ( fname ) )
2007-09-09 00:49:43 +04:00
return pm_process ( fname , do_section , do_parameter , lp_ctx ) ;
2003-08-13 05:53:07 +04:00
DEBUG ( 2 , ( " Can't find include file %s \n " , fname ) ) ;
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
/***************************************************************************
Handle the interpretation of the copy parameter .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-10 15:01:20 +03:00
static bool handle_copy ( struct loadparm_context * lp_ctx ,
2007-09-09 00:49:43 +04:00
const char * pszParmValue , char * * ptr )
2003-08-13 05:53:07 +04:00
{
2007-09-08 04:07:50 +04:00
bool bRetval ;
2007-09-09 00:03:19 +04:00
struct loadparm_service * serviceTemp ;
2003-08-13 05:53:07 +04:00
2007-12-09 01:31:41 +03:00
string_set ( lp_ctx , ptr , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
2007-09-08 04:07:50 +04:00
bRetval = false ;
2003-08-13 05:53:07 +04:00
DEBUG ( 3 , ( " Copying service from service %s \n " , pszParmValue ) ) ;
2007-09-09 00:49:43 +04:00
if ( ( serviceTemp = getservicebyname ( lp_ctx , pszParmValue ) ) ! = NULL ) {
if ( serviceTemp = = lp_ctx - > currentService ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 , ( " Can't copy service %s - unable to copy self! \n " , pszParmValue ) ) ;
} else {
2007-09-09 00:49:43 +04:00
copy_service ( lp_ctx - > currentService ,
2007-09-08 04:07:50 +04:00
serviceTemp ,
2007-09-09 00:49:43 +04:00
lp_ctx - > currentService - > copymap ) ;
2007-09-08 04:07:50 +04:00
bRetval = true ;
2003-08-13 05:53:07 +04:00
}
} else {
2008-02-10 15:01:20 +03:00
DEBUG ( 0 , ( " Unable to copy service - source not found: %s \n " ,
2007-09-09 00:49:43 +04:00
pszParmValue ) ) ;
2007-09-08 04:07:50 +04:00
bRetval = false ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 03:37:00 +04:00
return bRetval ;
2003-08-13 05:53:07 +04:00
}
2008-02-10 15:01:20 +03:00
static bool handle_debuglevel ( struct loadparm_context * lp_ctx ,
2007-12-09 01:31:49 +03:00
const char * pszParmValue , char * * ptr )
{
DEBUGLEVEL = atoi ( pszParmValue ) ;
return true ;
}
2008-02-10 15:01:20 +03:00
static bool handle_logfile ( struct loadparm_context * lp_ctx ,
2007-12-09 01:31:49 +03:00
const char * pszParmValue , char * * ptr )
{
logfile = pszParmValue ;
return true ;
}
2003-08-13 05:53:07 +04:00
/***************************************************************************
Initialise a copymap .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-09-09 00:03:19 +04:00
static void init_copymap ( struct loadparm_service * pservice )
2003-08-13 05:53:07 +04:00
{
int i ;
2007-09-08 04:48:23 +04:00
talloc_free ( pservice - > copymap ) ;
pservice - > copymap = talloc_array ( pservice , int , NUMPARAMETERS ) ;
if ( pservice - > copymap = = NULL ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 ,
( " Couldn't allocate copymap!! (size %d) \n " ,
( int ) NUMPARAMETERS ) ) ;
2007-09-08 04:48:23 +04:00
return ;
}
for ( i = 0 ; i < NUMPARAMETERS ; i + + )
pservice - > copymap [ i ] = true ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Process a parametric option
*/
2008-02-10 15:01:20 +03:00
static bool lp_do_parameter_parametric ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service ,
const char * pszParmName ,
2007-09-08 04:07:50 +04:00
const char * pszParmValue , int flags )
2003-08-13 05:53:07 +04:00
{
struct param_opt * paramo , * data ;
char * name ;
2007-09-08 04:38:22 +04:00
TALLOC_CTX * mem_ctx ;
2003-08-13 05:53:07 +04:00
2005-07-13 02:22:59 +04:00
while ( isspace ( ( unsigned char ) * pszParmName ) ) {
2003-08-15 23:09:52 +04:00
pszParmName + + ;
}
2003-08-13 05:53:07 +04:00
name = strdup ( pszParmName ) ;
2007-09-08 18:12:45 +04:00
if ( ! name ) return false ;
2003-08-13 05:53:07 +04:00
strlower ( name ) ;
2007-09-08 18:12:45 +04:00
if ( service = = NULL ) {
2007-12-09 01:31:55 +03:00
data = lp_ctx - > globals - > param_opt ;
mem_ctx = lp_ctx - > globals ;
2003-08-13 05:53:07 +04:00
} else {
2007-09-08 18:12:45 +04:00
data = service - > param_opt ;
mem_ctx = service ;
2003-08-13 05:53:07 +04:00
}
/* Traverse destination */
for ( paramo = data ; paramo ; paramo = paramo - > next ) {
/* If we already have the option set, override it unless
it was a command line option and the new one isn ' t */
if ( strcmp ( paramo - > key , name ) = = 0 ) {
if ( ( paramo - > flags & FLAG_CMDLINE ) & &
! ( flags & FLAG_CMDLINE ) ) {
2007-09-08 18:12:45 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 04:38:22 +04:00
talloc_free ( paramo - > value ) ;
paramo - > value = talloc_strdup ( paramo , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
paramo - > flags = flags ;
free ( name ) ;
2007-09-08 18:12:45 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
}
2007-09-08 04:38:22 +04:00
paramo = talloc ( mem_ctx , struct param_opt ) ;
2005-09-28 23:56:21 +04:00
if ( ! paramo )
smb_panic ( " OOM " ) ;
2007-09-08 04:38:22 +04:00
paramo - > key = talloc_strdup ( paramo , name ) ;
paramo - > value = talloc_strdup ( paramo , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
paramo - > flags = flags ;
2007-09-08 18:12:45 +04:00
if ( service = = NULL ) {
2007-12-09 01:31:55 +03:00
DLIST_ADD ( lp_ctx - > globals - > param_opt , paramo ) ;
2003-08-13 05:53:07 +04:00
} else {
2007-09-08 18:12:45 +04:00
DLIST_ADD ( service - > param_opt , paramo ) ;
2003-08-13 05:53:07 +04:00
}
free ( name ) ;
2008-02-10 15:01:20 +03:00
2007-09-08 04:38:22 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2008-02-10 15:01:20 +03:00
static bool set_variable ( TALLOC_CTX * mem_ctx , int parmnum , void * parm_ptr ,
2007-09-09 00:49:43 +04:00
const char * pszParmName , const char * pszParmValue ,
struct loadparm_context * lp_ctx )
2003-08-13 05:53:07 +04:00
{
2007-09-08 18:12:45 +04:00
int i ;
2003-08-13 05:53:07 +04:00
/* if it is a special case then go ahead */
if ( parm_table [ parmnum ] . special ) {
2008-02-10 15:01:20 +03:00
parm_table [ parmnum ] . special ( lp_ctx , pszParmValue ,
2007-09-09 00:49:43 +04:00
( char * * ) parm_ptr ) ;
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
/* now switch on the type of variable it is */
switch ( parm_table [ parmnum ] . type )
{
2006-09-16 18:58:51 +04:00
case P_BOOL : {
2007-09-08 18:12:45 +04:00
bool b ;
2006-09-16 18:58:51 +04:00
if ( ! set_boolean ( pszParmValue , & b ) ) {
2006-01-28 15:15:24 +03:00
DEBUG ( 0 , ( " lp_do_parameter(%s): value is not boolean! \n " , pszParmValue ) ) ;
2007-09-08 18:12:45 +04:00
return false ;
2006-01-28 15:15:24 +03:00
}
2006-09-16 18:58:51 +04:00
* ( int * ) parm_ptr = b ;
}
2003-08-13 05:53:07 +04:00
break ;
case P_INTEGER :
* ( int * ) parm_ptr = atoi ( pszParmValue ) ;
break ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
case P_OCTAL :
* ( int * ) parm_ptr = strtol ( pszParmValue , NULL , 8 ) ;
break ;
2006-04-24 04:38:53 +04:00
case P_BYTES :
{
uint64_t val ;
if ( conv_str_size ( pszParmValue , & val ) ) {
if ( val < = INT_MAX ) {
* ( int * ) parm_ptr = ( int ) val ;
break ;
}
}
DEBUG ( 0 , ( " lp_do_parameter(%s): value is not "
" a valid size specifier! \n " , pszParmValue ) ) ;
2007-09-08 18:12:45 +04:00
return false ;
2006-04-24 04:38:53 +04:00
}
2003-08-13 05:53:07 +04:00
case P_LIST :
2008-02-10 15:01:20 +03:00
* ( const char * * * ) parm_ptr = str_list_make ( mem_ctx ,
2005-02-14 13:08:10 +03:00
pszParmValue , NULL ) ;
2003-08-13 05:53:07 +04:00
break ;
case P_STRING :
2007-09-08 17:27:14 +04:00
string_set ( mem_ctx , ( char * * ) parm_ptr , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
break ;
case P_USTRING :
2007-09-08 17:27:14 +04:00
string_set ( mem_ctx , ( char * * ) parm_ptr , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
strupper ( * ( char * * ) parm_ptr ) ;
break ;
case P_ENUM :
for ( i = 0 ; parm_table [ parmnum ] . enum_list [ i ] . name ; i + + ) {
if ( strequal
( pszParmValue ,
parm_table [ parmnum ] . enum_list [ i ] . name ) ) {
* ( int * ) parm_ptr =
parm_table [ parmnum ] .
enum_list [ i ] . value ;
break ;
}
}
2004-09-13 09:05:46 +04:00
if ( ! parm_table [ parmnum ] . enum_list [ i ] . name ) {
DEBUG ( 0 , ( " Unknown enumerated value '%s' for '%s' \n " ,
pszParmValue , pszParmName ) ) ;
2007-09-08 18:12:45 +04:00
return false ;
2004-09-13 09:05:46 +04:00
}
2003-08-13 05:53:07 +04:00
break ;
}
2007-12-09 01:32:33 +03:00
if ( lp_ctx - > flags [ parmnum ] & FLAG_DEFAULT ) {
lp_ctx - > flags [ parmnum ] & = ~ FLAG_DEFAULT ;
2006-01-06 05:13:01 +03:00
/* we have to also unset FLAG_DEFAULT on aliases */
2007-12-07 18:04:22 +03:00
for ( i = parmnum - 1 ; i > = 0 & & parm_table [ i ] . offset = = parm_table [ parmnum ] . offset ; i - - ) {
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ i ] & = ~ FLAG_DEFAULT ;
2006-01-06 05:13:01 +03:00
}
2007-12-07 18:04:22 +03:00
for ( i = parmnum + 1 ; i < NUMPARAMETERS & & parm_table [ i ] . offset = = parm_table [ parmnum ] . offset ; i + + ) {
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ i ] & = ~ FLAG_DEFAULT ;
2006-01-06 05:13:01 +03:00
}
}
2007-09-08 18:12:45 +04:00
return true ;
}
2008-02-10 15:01:20 +03:00
bool lp_do_global_parameter ( struct loadparm_context * lp_ctx ,
2007-09-08 21:25:24 +04:00
const char * pszParmName , const char * pszParmValue )
2007-09-08 18:12:45 +04:00
{
int parmnum = map_parameter ( pszParmName ) ;
void * parm_ptr ;
if ( parmnum < 0 ) {
if ( strchr ( pszParmName , ' : ' ) ) {
2007-09-29 22:00:19 +04:00
return lp_do_parameter_parametric ( lp_ctx , NULL , pszParmName , pszParmValue , 0 ) ;
2007-09-08 18:12:45 +04:00
}
DEBUG ( 0 , ( " Ignoring unknown parameter \" %s \" \n " , pszParmName ) ) ;
return true ;
}
2006-01-06 05:13:01 +03:00
2007-09-08 18:12:45 +04:00
/* if the flag has been set on the command line, then don't allow override,
but don ' t report an error */
2007-12-09 01:32:33 +03:00
if ( lp_ctx - > flags [ parmnum ] & FLAG_CMDLINE ) {
2007-09-08 18:12:45 +04:00
return true ;
}
2007-12-07 18:04:22 +03:00
parm_ptr = lp_parm_ptr ( lp_ctx , NULL , & parm_table [ parmnum ] ) ;
2007-09-08 18:12:45 +04:00
2008-02-10 15:01:20 +03:00
return set_variable ( lp_ctx , parmnum , parm_ptr ,
2007-09-09 00:49:43 +04:00
pszParmName , pszParmValue , lp_ctx ) ;
2007-09-08 18:12:45 +04:00
}
2008-02-10 15:01:20 +03:00
bool lp_do_service_parameter ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service ,
2007-09-08 18:12:45 +04:00
const char * pszParmName , const char * pszParmValue )
{
void * parm_ptr ;
int i ;
int parmnum = map_parameter ( pszParmName ) ;
if ( parmnum < 0 ) {
if ( strchr ( pszParmName , ' : ' ) ) {
2007-09-29 22:00:19 +04:00
return lp_do_parameter_parametric ( lp_ctx , service , pszParmName , pszParmValue , 0 ) ;
2007-09-08 18:12:45 +04:00
}
DEBUG ( 0 , ( " Ignoring unknown parameter \" %s \" \n " , pszParmName ) ) ;
return true ;
}
/* if the flag has been set on the command line, then don't allow override,
but don ' t report an error */
2007-12-09 01:32:33 +03:00
if ( lp_ctx - > flags [ parmnum ] & FLAG_CMDLINE ) {
2007-09-08 18:12:45 +04:00
return true ;
}
if ( parm_table [ parmnum ] . class = = P_GLOBAL ) {
DEBUG ( 0 ,
( " Global parameter %s found in service section! \n " ,
pszParmName ) ) ;
return true ;
}
2007-12-07 18:04:22 +03:00
parm_ptr = ( ( char * ) service ) + parm_table [ parmnum ] . offset ;
2007-09-08 18:12:45 +04:00
if ( ! service - > copymap )
init_copymap ( service ) ;
2008-02-10 15:01:20 +03:00
/* this handles the aliases - set the copymap for other
2007-09-08 18:12:45 +04:00
* entries with the same data pointer */
for ( i = 0 ; parm_table [ i ] . label ; i + + )
2008-02-10 15:01:20 +03:00
if ( parm_table [ i ] . offset = = parm_table [ parmnum ] . offset & &
2007-12-07 18:04:22 +03:00
parm_table [ i ] . class = = parm_table [ parmnum ] . class )
2007-09-08 18:12:45 +04:00
service - > copymap [ i ] = false ;
2008-02-10 15:01:20 +03:00
return set_variable ( service , parmnum , parm_ptr , pszParmName ,
2007-09-09 00:49:43 +04:00
pszParmValue , lp_ctx ) ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Process a parameter .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
static bool do_parameter ( const char * pszParmName , const char * pszParmValue ,
2007-09-08 18:12:45 +04:00
void * userdata )
2003-08-13 05:53:07 +04:00
{
2007-09-09 00:49:43 +04:00
struct loadparm_context * lp_ctx = ( struct loadparm_context * ) userdata ;
2008-02-10 15:01:20 +03:00
if ( lp_ctx - > bInGlobalSection )
return lp_do_global_parameter ( lp_ctx , pszParmName ,
2007-09-08 21:25:24 +04:00
pszParmValue ) ;
2008-02-10 15:01:20 +03:00
else
2007-09-09 00:49:43 +04:00
return lp_do_service_parameter ( lp_ctx , lp_ctx - > currentService ,
2007-09-08 18:12:45 +04:00
pszParmName , pszParmValue ) ;
2003-08-13 05:53:07 +04:00
}
2004-09-13 09:05:46 +04:00
/*
variable argument do parameter
*/
2007-09-08 21:25:24 +04:00
bool lp_do_global_parameter_var ( struct loadparm_context * lp_ctx , const char * pszParmName , const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 3 , 4 ) ;
2008-02-10 15:01:20 +03:00
bool lp_do_global_parameter_var ( struct loadparm_context * lp_ctx ,
const char * pszParmName , const char * fmt , . . . )
2004-09-13 09:05:46 +04:00
{
char * s ;
2007-09-08 18:12:45 +04:00
bool ret ;
2004-09-13 09:05:46 +04:00
va_list ap ;
2008-02-10 15:01:20 +03:00
va_start ( ap , fmt ) ;
2004-09-13 09:05:46 +04:00
s = talloc_vasprintf ( NULL , fmt , ap ) ;
va_end ( ap ) ;
2007-09-08 21:25:24 +04:00
ret = lp_do_global_parameter ( lp_ctx , pszParmName , s ) ;
2004-09-13 09:05:46 +04:00
talloc_free ( s ) ;
return ret ;
}
2003-08-13 05:53:07 +04:00
/*
set a parameter from the commandline - this is called from command line parameter
parsing code . It sets the parameter then marks the parameter as unable to be modified
by smb . conf processing
*/
2008-02-10 15:01:20 +03:00
bool lp_set_cmdline ( struct loadparm_context * lp_ctx , const char * pszParmName ,
2007-09-28 03:31:28 +04:00
const char * pszParmValue )
2003-08-13 05:53:07 +04:00
{
int parmnum = map_parameter ( pszParmName ) ;
2004-09-13 07:55:28 +04:00
int i ;
2003-08-13 05:53:07 +04:00
2005-07-13 02:22:59 +04:00
while ( isspace ( ( unsigned char ) * pszParmValue ) ) pszParmValue + + ;
2004-10-19 14:02:02 +04:00
2003-08-13 05:53:07 +04:00
if ( parmnum < 0 & & strchr ( pszParmName , ' : ' ) ) {
/* set a parametric option */
2008-02-10 15:01:20 +03:00
return lp_do_parameter_parametric ( lp_ctx , NULL , pszParmName ,
2007-09-29 22:00:19 +04:00
pszParmValue , FLAG_CMDLINE ) ;
2003-08-13 05:53:07 +04:00
}
2004-10-26 04:59:06 +04:00
if ( parmnum < 0 ) {
DEBUG ( 0 , ( " Unknown option '%s' \n " , pszParmName ) ) ;
2007-09-08 18:12:45 +04:00
return false ;
2004-10-26 04:59:06 +04:00
}
2003-08-13 05:53:07 +04:00
/* reset the CMDLINE flag in case this has been called before */
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ parmnum ] & = ~ FLAG_CMDLINE ;
2003-08-13 05:53:07 +04:00
2007-09-28 03:31:28 +04:00
if ( ! lp_do_global_parameter ( lp_ctx , pszParmName , pszParmValue ) ) {
2007-09-08 18:12:45 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ parmnum ] | = FLAG_CMDLINE ;
2004-09-13 07:55:28 +04:00
/* we have to also set FLAG_CMDLINE on aliases */
2007-12-07 18:04:22 +03:00
for ( i = parmnum - 1 ; i > = 0 & & parm_table [ i ] . offset = = parm_table [ parmnum ] . offset ; i - - ) {
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ i ] | = FLAG_CMDLINE ;
2004-09-13 07:55:28 +04:00
}
2007-12-07 18:04:22 +03:00
for ( i = parmnum + 1 ; i < NUMPARAMETERS & & parm_table [ i ] . offset = = parm_table [ parmnum ] . offset ; i + + ) {
2007-12-09 01:32:33 +03:00
lp_ctx - > flags [ i ] | = FLAG_CMDLINE ;
2004-09-13 07:55:28 +04:00
}
2007-09-08 18:12:45 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
2004-09-13 05:27:37 +04:00
/*
set a option from the commandline in ' a = b ' format . Use to support - - option
*/
2007-09-28 03:31:28 +04:00
bool lp_set_option ( struct loadparm_context * lp_ctx , const char * option )
2004-09-13 05:27:37 +04:00
{
char * p , * s ;
2007-09-08 18:12:45 +04:00
bool ret ;
2004-09-13 05:27:37 +04:00
s = strdup ( option ) ;
if ( ! s ) {
2007-09-08 18:12:45 +04:00
return false ;
2004-09-13 05:27:37 +04:00
}
p = strchr ( s , ' = ' ) ;
if ( ! p ) {
free ( s ) ;
2007-09-08 18:12:45 +04:00
return false ;
2004-09-13 05:27:37 +04:00
}
* p = 0 ;
2007-09-28 03:31:28 +04:00
ret = lp_set_cmdline ( lp_ctx , s , p + 1 ) ;
2004-09-13 05:27:37 +04:00
free ( s ) ;
return ret ;
}
2005-02-10 10:39:14 +03:00
# define BOOLSTR(b) ((b) ? "Yes" : "No")
2007-12-09 01:32:33 +03:00
/**
* Print a parameter of the specified type .
*/
2003-08-13 05:53:07 +04:00
static void print_parameter ( struct parm_struct * p , void * ptr , FILE * f )
{
int i ;
switch ( p - > type )
{
case P_ENUM :
for ( i = 0 ; p - > enum_list [ i ] . name ; i + + ) {
if ( * ( int * ) ptr = = p - > enum_list [ i ] . value ) {
fprintf ( f , " %s " ,
p - > enum_list [ i ] . name ) ;
break ;
}
}
break ;
case P_BOOL :
2007-09-08 18:12:45 +04:00
fprintf ( f , " %s " , BOOLSTR ( ( bool ) * ( int * ) ptr ) ) ;
2003-08-13 05:53:07 +04:00
break ;
case P_INTEGER :
2006-04-24 04:38:53 +04:00
case P_BYTES :
2003-08-13 05:53:07 +04:00
fprintf ( f , " %d " , * ( int * ) ptr ) ;
break ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
case P_OCTAL :
fprintf ( f , " 0%o " , * ( int * ) ptr ) ;
break ;
2003-08-13 05:53:07 +04:00
case P_LIST :
if ( ( char * * * ) ptr & & * ( char * * * ) ptr ) {
char * * list = * ( char * * * ) ptr ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
for ( ; * list ; list + + )
fprintf ( f , " %s%s " , * list ,
( ( * ( list + 1 ) ) ? " , " : " " ) ) ;
}
break ;
case P_STRING :
case P_USTRING :
if ( * ( char * * ) ptr ) {
fprintf ( f , " %s " , * ( char * * ) ptr ) ;
}
break ;
}
}
2007-12-09 01:32:33 +03:00
/**
* Check if two parameters are equal .
*/
2003-08-13 05:53:07 +04:00
2007-09-08 18:12:45 +04:00
static bool equal_parameter ( parm_type type , void * ptr1 , void * ptr2 )
2003-08-13 05:53:07 +04:00
{
switch ( type ) {
case P_BOOL :
2006-05-24 10:36:17 +04:00
return ( * ( ( int * ) ptr1 ) = = * ( ( int * ) ptr2 ) ) ;
2003-08-13 05:53:07 +04:00
case P_INTEGER :
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
case P_OCTAL :
2006-04-24 04:38:53 +04:00
case P_BYTES :
2003-08-13 05:53:07 +04:00
case P_ENUM :
return ( * ( ( int * ) ptr1 ) = = * ( ( int * ) ptr2 ) ) ;
case P_LIST :
2008-02-10 15:01:20 +03:00
return str_list_equal ( ( const char * * ) ( * ( char * * * ) ptr1 ) ,
2005-02-04 07:58:48 +03:00
( const char * * ) ( * ( char * * * ) ptr2 ) ) ;
2003-08-13 05:53:07 +04:00
case P_STRING :
case P_USTRING :
{
char * p1 = * ( char * * ) ptr1 , * p2 = * ( char * * ) ptr2 ;
if ( p1 & & ! * p1 )
p1 = NULL ;
if ( p2 & & ! * p2 )
p2 = NULL ;
return ( p1 = = p2 | | strequal ( p1 , p2 ) ) ;
}
}
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
2008-02-10 15:01:20 +03:00
* Process a new section ( service ) .
2007-12-09 01:32:33 +03:00
*
* At this stage all sections are services .
* Later we ' ll have special sections that permit server parameters to be set .
2008-02-10 15:01:20 +03:00
* Returns True on success , False on failure .
2007-12-09 01:32:33 +03:00
*/
2003-08-13 05:53:07 +04:00
2007-09-08 18:12:45 +04:00
static bool do_section ( const char * pszSectionName , void * userdata )
2003-08-13 05:53:07 +04:00
{
2007-09-08 23:16:08 +04:00
struct loadparm_context * lp_ctx = ( struct loadparm_context * ) userdata ;
2007-09-08 18:12:45 +04:00
bool bRetval ;
bool isglobal = ( ( strwicmp ( pszSectionName , GLOBAL_NAME ) = = 0 ) | |
2003-08-13 05:53:07 +04:00
( strwicmp ( pszSectionName , GLOBAL_NAME2 ) = = 0 ) ) ;
2007-09-08 18:12:45 +04:00
bRetval = false ;
2003-08-13 05:53:07 +04:00
/* if we've just struck a global section, note the fact. */
2007-09-08 23:16:08 +04:00
lp_ctx - > bInGlobalSection = isglobal ;
2003-08-13 05:53:07 +04:00
/* check for multiple global sections */
2007-09-08 23:16:08 +04:00
if ( lp_ctx - > bInGlobalSection ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 3 , ( " Processing section \" [%s] \" \n " , pszSectionName ) ) ;
2007-09-08 03:37:00 +04:00
return true ;
2003-08-13 05:53:07 +04:00
}
/* if we have a current service, tidy it up before moving on */
2007-09-08 18:12:45 +04:00
bRetval = true ;
2003-08-13 05:53:07 +04:00
2007-09-08 23:16:08 +04:00
if ( lp_ctx - > currentService ! = NULL )
bRetval = service_ok ( lp_ctx - > currentService ) ;
2003-08-13 05:53:07 +04:00
/* if all is still well, move to the next record in the services array */
if ( bRetval ) {
/* We put this here to avoid an odd message order if messages are */
/* issued by the post-processing of a previous section. */
DEBUG ( 2 , ( " Processing section \" [%s] \" \n " , pszSectionName ) ) ;
2008-02-28 22:04:58 +03:00
if ( ( lp_ctx - > currentService = lp_add_service ( lp_ctx , lp_ctx - > sDefault ,
2007-09-08 23:16:08 +04:00
pszSectionName ) )
2007-09-08 18:12:45 +04:00
= = NULL ) {
2003-08-13 05:53:07 +04:00
DEBUG ( 0 , ( " Failed to add a new service \n " ) ) ;
2007-09-08 03:37:00 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
}
2007-09-08 03:37:00 +04:00
return bRetval ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
2008-02-28 22:04:58 +03:00
* Determine if a particular base parameter is currently set to the default value .
2007-12-09 01:32:33 +03:00
*/
2003-08-13 05:53:07 +04:00
2008-02-28 22:04:58 +03:00
static bool is_default ( struct loadparm_service * sDefault , int i )
2003-08-13 05:53:07 +04:00
{
2008-02-28 22:04:58 +03:00
void * def_ptr = ( ( char * ) sDefault ) + parm_table [ i ] . offset ;
2003-08-13 05:53:07 +04:00
if ( ! defaults_saved )
2007-09-08 18:12:45 +04:00
return false ;
2003-08-13 05:53:07 +04:00
switch ( parm_table [ i ] . type ) {
case P_LIST :
2005-02-04 07:58:48 +03:00
return str_list_equal ( ( const char * * ) parm_table [ i ] . def . lvalue ,
2007-12-07 18:04:22 +03:00
( const char * * ) def_ptr ) ;
2003-08-13 05:53:07 +04:00
case P_STRING :
case P_USTRING :
return strequal ( parm_table [ i ] . def . svalue ,
2007-12-07 18:04:22 +03:00
* ( char * * ) def_ptr ) ;
2003-08-13 05:53:07 +04:00
case P_BOOL :
return parm_table [ i ] . def . bvalue = =
2007-12-07 18:04:22 +03:00
* ( int * ) def_ptr ;
2003-08-13 05:53:07 +04:00
case P_INTEGER :
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
case P_OCTAL :
2006-04-24 04:38:53 +04:00
case P_BYTES :
2003-08-13 05:53:07 +04:00
case P_ENUM :
return parm_table [ i ] . def . ivalue = =
2007-12-07 18:04:22 +03:00
* ( int * ) def_ptr ;
2003-08-13 05:53:07 +04:00
}
2007-09-08 18:12:45 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Display the contents of the global structure .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
static void dump_globals ( struct loadparm_context * lp_ctx , FILE * f ,
2007-12-09 01:32:01 +03:00
bool show_defaults )
2003-08-13 05:53:07 +04:00
{
int i ;
struct param_opt * data ;
2008-02-10 15:01:20 +03:00
2003-08-13 05:53:07 +04:00
fprintf ( f , " # Global parameters \n [global] \n " ) ;
for ( i = 0 ; parm_table [ i ] . label ; i + + )
if ( parm_table [ i ] . class = = P_GLOBAL & &
2007-12-07 18:04:22 +03:00
parm_table [ i ] . offset ! = - 1 & &
( i = = 0 | | ( parm_table [ i ] . offset ! = parm_table [ i - 1 ] . offset ) ) ) {
2007-12-09 01:32:33 +03:00
if ( ! show_defaults & & ( lp_ctx - > flags [ i ] & FLAG_DEFAULT ) )
2003-08-13 05:53:07 +04:00
continue ;
fprintf ( f , " \t %s = " , parm_table [ i ] . label ) ;
2007-12-07 18:04:22 +03:00
print_parameter ( & parm_table [ i ] , lp_parm_ptr ( lp_ctx , NULL , & parm_table [ i ] ) , f ) ;
2003-08-13 05:53:07 +04:00
fprintf ( f , " \n " ) ;
}
2007-12-09 01:31:55 +03:00
if ( lp_ctx - > globals - > param_opt ! = NULL ) {
2008-02-10 15:01:20 +03:00
for ( data = lp_ctx - > globals - > param_opt ; data ;
2007-09-08 05:29:52 +04:00
data = data - > next ) {
2003-08-13 05:53:07 +04:00
fprintf ( f , " \t %s = %s \n " , data - > key , data - > value ) ;
}
}
}
2007-12-09 01:32:33 +03:00
/**
* Display the contents of a single services record .
*/
2003-08-13 05:53:07 +04:00
2008-02-28 22:04:58 +03:00
static void dump_a_service ( struct loadparm_service * pService , struct loadparm_service * sDefault , FILE * f )
2003-08-13 05:53:07 +04:00
{
int i ;
struct param_opt * data ;
2008-02-10 15:01:20 +03:00
2008-02-28 22:04:58 +03:00
if ( pService ! = sDefault )
2003-08-13 05:53:07 +04:00
fprintf ( f , " \n [%s] \n " , pService - > szService ) ;
for ( i = 0 ; parm_table [ i ] . label ; i + + )
if ( parm_table [ i ] . class = = P_LOCAL & &
2007-12-07 18:04:22 +03:00
parm_table [ i ] . offset ! = - 1 & &
2003-08-13 05:53:07 +04:00
( * parm_table [ i ] . label ! = ' - ' ) & &
2007-12-07 18:04:22 +03:00
( i = = 0 | | ( parm_table [ i ] . offset ! = parm_table [ i - 1 ] . offset ) ) ) {
2008-02-28 22:04:58 +03:00
if ( pService = = sDefault ) {
if ( defaults_saved & & is_default ( sDefault , i ) )
2003-08-13 05:53:07 +04:00
continue ;
} else {
if ( equal_parameter ( parm_table [ i ] . type ,
( ( char * ) pService ) +
2007-12-07 18:04:22 +03:00
parm_table [ i ] . offset ,
2008-02-28 22:04:58 +03:00
( ( char * ) sDefault ) +
2007-12-07 18:04:22 +03:00
parm_table [ i ] . offset ) )
2003-08-13 05:53:07 +04:00
continue ;
}
fprintf ( f , " \t %s = " , parm_table [ i ] . label ) ;
print_parameter ( & parm_table [ i ] ,
2007-12-07 18:04:22 +03:00
( ( char * ) pService ) + parm_table [ i ] . offset , f ) ;
2003-08-13 05:53:07 +04:00
fprintf ( f , " \n " ) ;
}
if ( pService - > param_opt ! = NULL ) {
2007-09-08 05:29:52 +04:00
for ( data = pService - > param_opt ; data ; data = data - > next ) {
2003-08-13 05:53:07 +04:00
fprintf ( f , " \t %s = %s \n " , data - > key , data - > value ) ;
}
}
}
2008-02-10 15:01:20 +03:00
bool lp_dump_a_parameter ( struct loadparm_context * lp_ctx ,
struct loadparm_service * service ,
2007-12-09 01:32:05 +03:00
const char * parm_name , FILE * f )
2006-01-06 05:28:36 +03:00
{
2006-01-06 05:50:46 +03:00
struct parm_struct * parm ;
void * ptr ;
2008-02-10 15:01:20 +03:00
2006-01-06 05:50:46 +03:00
parm = lp_parm_struct ( parm_name ) ;
if ( ! parm ) {
2007-09-08 18:12:45 +04:00
return false ;
2006-01-06 05:28:36 +03:00
}
2007-12-07 18:04:22 +03:00
2007-12-09 01:32:05 +03:00
ptr = lp_parm_ptr ( lp_ctx , service , parm ) ;
2008-02-10 15:01:20 +03:00
2007-12-07 18:04:22 +03:00
print_parameter ( parm , ptr , f ) ;
2006-01-06 05:50:46 +03:00
fprintf ( f , " \n " ) ;
2007-09-08 18:12:45 +04:00
return true ;
2006-01-06 05:28:36 +03:00
}
2003-08-13 05:53:07 +04:00
2007-12-09 01:32:33 +03:00
/**
* Return info about the next service in a service . snum = = - 1 gives the globals .
* Return NULL when out of parameters .
*/
2003-08-13 05:53:07 +04:00
2007-09-28 03:31:28 +04:00
struct parm_struct * lp_next_parameter ( struct loadparm_context * lp_ctx , int snum , int * i ,
int allparameters )
2003-08-13 05:53:07 +04:00
{
if ( snum = = - 1 ) {
/* do the globals */
for ( ; parm_table [ * i ] . label ; ( * i ) + + ) {
2007-12-07 18:04:22 +03:00
if ( parm_table [ * i ] . offset = = - 1
2003-08-13 05:53:07 +04:00
| | ( * parm_table [ * i ] . label = = ' - ' ) )
continue ;
if ( ( * i ) > 0
2007-12-07 18:04:22 +03:00
& & ( parm_table [ * i ] . offset = =
parm_table [ ( * i ) - 1 ] . offset ) )
2003-08-13 05:53:07 +04:00
continue ;
return & parm_table [ ( * i ) + + ] ;
}
} else {
2007-12-09 01:32:01 +03:00
struct loadparm_service * pService = lp_ctx - > services [ snum ] ;
2003-08-13 05:53:07 +04:00
for ( ; parm_table [ * i ] . label ; ( * i ) + + ) {
if ( parm_table [ * i ] . class = = P_LOCAL & &
2007-12-07 18:04:22 +03:00
parm_table [ * i ] . offset ! = - 1 & &
2003-08-13 05:53:07 +04:00
( * parm_table [ * i ] . label ! = ' - ' ) & &
( ( * i ) = = 0 | |
2007-12-07 18:04:22 +03:00
( parm_table [ * i ] . offset ! =
parm_table [ ( * i ) - 1 ] . offset ) ) )
2003-08-13 05:53:07 +04:00
{
if ( allparameters | |
! equal_parameter ( parm_table [ * i ] . type ,
( ( char * ) pService ) +
2007-12-07 18:04:22 +03:00
parm_table [ * i ] . offset ,
2008-02-28 22:04:58 +03:00
( ( char * ) lp_ctx - > sDefault ) +
2007-12-07 18:04:22 +03:00
parm_table [ * i ] . offset ) )
2003-08-13 05:53:07 +04:00
{
return & parm_table [ ( * i ) + + ] ;
}
}
}
}
return NULL ;
}
2007-12-09 01:32:27 +03:00
/**
* Auto - load some home services .
*/
2008-02-10 15:01:20 +03:00
static void lp_add_auto_services ( struct loadparm_context * lp_ctx ,
2007-09-08 23:16:08 +04:00
const char * str )
2003-08-13 05:53:07 +04:00
{
2004-05-25 02:05:06 +04:00
return ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:33 +03:00
/**
* Unload unused services .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
void lp_killunused ( struct loadparm_context * lp_ctx ,
struct smbsrv_connection * smb ,
2007-09-28 03:31:28 +04:00
bool ( * snumused ) ( struct smbsrv_connection * , int ) )
2003-08-13 05:53:07 +04:00
{
int i ;
2007-09-28 03:31:28 +04:00
for ( i = 0 ; i < lp_ctx - > iNumServices ; i + + ) {
2007-12-09 01:32:01 +03:00
if ( lp_ctx - > services [ i ] = = NULL )
2003-08-13 05:53:07 +04:00
continue ;
if ( ! snumused | | ! snumused ( smb , i ) ) {
2007-12-09 01:32:01 +03:00
talloc_free ( lp_ctx - > services [ i ] ) ;
lp_ctx - > services [ i ] = NULL ;
2003-08-13 05:53:07 +04:00
}
}
}
2007-12-09 01:31:41 +03:00
static int lp_destructor ( struct loadparm_context * lp_ctx )
{
struct param_opt * data ;
2007-12-09 01:31:55 +03:00
if ( lp_ctx - > globals - > param_opt ! = NULL ) {
2007-12-09 01:31:41 +03:00
struct param_opt * next ;
2007-12-09 01:31:55 +03:00
for ( data = lp_ctx - > globals - > param_opt ; data ; data = next ) {
2007-12-09 01:31:41 +03:00
next = data - > next ;
if ( data - > flags & FLAG_CMDLINE ) continue ;
2007-12-09 01:31:55 +03:00
DLIST_REMOVE ( lp_ctx - > globals - > param_opt , data ) ;
2007-12-09 01:31:41 +03:00
talloc_free ( data ) ;
}
}
return 0 ;
}
2007-12-09 01:32:27 +03:00
/**
* Initialise the global parameter structure .
*/
2007-12-09 01:31:41 +03:00
struct loadparm_context * loadparm_init ( TALLOC_CTX * mem_ctx )
2007-09-08 21:25:24 +04:00
{
int i ;
char * myname ;
2007-12-09 01:31:41 +03:00
struct loadparm_context * lp_ctx ;
2007-09-08 21:25:24 +04:00
2007-12-09 01:31:55 +03:00
lp_ctx = talloc_zero ( mem_ctx , struct loadparm_context ) ;
2007-12-09 01:31:41 +03:00
if ( lp_ctx = = NULL )
return NULL ;
talloc_set_destructor ( lp_ctx , lp_destructor ) ;
2007-09-27 23:49:53 +04:00
lp_ctx - > bInGlobalSection = true ;
2007-12-09 01:31:55 +03:00
lp_ctx - > globals = talloc_zero ( lp_ctx , struct loadparm_global ) ;
2008-02-28 22:04:58 +03:00
lp_ctx - > sDefault = talloc_zero ( lp_ctx , struct loadparm_service ) ;
lp_ctx - > sDefault - > iMaxPrintJobs = 1000 ;
lp_ctx - > sDefault - > bAvailable = true ;
lp_ctx - > sDefault - > bBrowseable = true ;
lp_ctx - > sDefault - > bRead_only = true ;
lp_ctx - > sDefault - > bMap_archive = true ;
lp_ctx - > sDefault - > bStrictLocking = true ;
2008-03-27 13:00:04 +03:00
lp_ctx - > sDefault - > bOplocks = true ;
2008-02-28 22:04:58 +03:00
lp_ctx - > sDefault - > iCreate_mask = 0744 ;
lp_ctx - > sDefault - > iCreate_force_mode = 0000 ;
lp_ctx - > sDefault - > iDir_mask = 0755 ;
lp_ctx - > sDefault - > iDir_force_mode = 0000 ;
2007-09-27 23:49:53 +04:00
2007-09-08 21:25:24 +04:00
DEBUG ( 3 , ( " Initialising global parameters \n " ) ) ;
for ( i = 0 ; parm_table [ i ] . label ; i + + ) {
if ( ( parm_table [ i ] . type = = P_STRING | |
parm_table [ i ] . type = = P_USTRING ) & &
2007-12-07 18:04:22 +03:00
parm_table [ i ] . offset ! = - 1 & &
2007-12-09 01:32:33 +03:00
! ( lp_ctx - > flags [ i ] & FLAG_CMDLINE ) ) {
2007-12-13 11:13:35 +03:00
char * * r ;
if ( parm_table [ i ] . class = = P_LOCAL ) {
2008-02-28 22:04:58 +03:00
r = ( char * * ) ( ( ( char * ) lp_ctx - > sDefault ) + parm_table [ i ] . offset ) ;
2007-12-13 11:13:35 +03:00
} else {
2007-12-13 12:28:18 +03:00
r = ( char * * ) ( ( ( char * ) lp_ctx - > globals ) + parm_table [ i ] . offset ) ;
2007-12-13 11:13:35 +03:00
}
2007-12-09 01:31:49 +03:00
* r = talloc_strdup ( lp_ctx , " " ) ;
2007-09-08 21:25:24 +04:00
}
}
lp_do_global_parameter ( lp_ctx , " share backend " , " classic " ) ;
2008-02-10 15:01:20 +03:00
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " server role " , " standalone " ) ;
/* options that can be set on the command line must be initialised via
the slower lp_do_global_parameter ( ) to ensure that FLAG_CMDLINE is obeyed */
# ifdef TCP_NODELAY
lp_do_global_parameter ( lp_ctx , " socket options " , " TCP_NODELAY " ) ;
# endif
lp_do_global_parameter ( lp_ctx , " workgroup " , DEFAULT_WORKGROUP ) ;
myname = get_myname ( ) ;
lp_do_global_parameter ( lp_ctx , " netbios name " , myname ) ;
SAFE_FREE ( myname ) ;
2007-12-11 11:01:56 +03:00
lp_do_global_parameter ( lp_ctx , " name resolve order " , " wins host bcast " ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " fstype " , FSTYPE_STRING ) ;
lp_do_global_parameter ( lp_ctx , " ntvfs handler " , " unixuid default " ) ;
lp_do_global_parameter ( lp_ctx , " max connections " , " -1 " ) ;
lp_do_global_parameter ( lp_ctx , " dcerpc endpoint servers " , " epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo " ) ;
2008-05-28 07:21:26 +04:00
lp_do_global_parameter ( lp_ctx , " server services " , " smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd " ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " ntptr providor " , " simple_ldb " ) ;
lp_do_global_parameter ( lp_ctx , " auth methods:domain controller " , " anonymous sam_ignoredomain " ) ;
lp_do_global_parameter ( lp_ctx , " auth methods:member server " , " anonymous sam winbind " ) ;
lp_do_global_parameter ( lp_ctx , " auth methods:standalone " , " anonymous sam_ignoredomain " ) ;
lp_do_global_parameter ( lp_ctx , " private dir " , dyn_PRIVATE_DIR ) ;
lp_do_global_parameter ( lp_ctx , " sam database " , " sam.ldb " ) ;
2008-02-17 22:25:13 +03:00
lp_do_global_parameter ( lp_ctx , " idmap database " , " idmap.ldb " ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " secrets database " , " secrets.ldb " ) ;
lp_do_global_parameter ( lp_ctx , " spoolss database " , " spoolss.ldb " ) ;
lp_do_global_parameter ( lp_ctx , " wins config database " , " wins_config.ldb " ) ;
lp_do_global_parameter ( lp_ctx , " wins database " , " wins.ldb " ) ;
lp_do_global_parameter ( lp_ctx , " registry:HKEY_LOCAL_MACHINE " , " hklm.ldb " ) ;
/* This hive should be dynamically generated by Samba using
data from the sam , but for the moment leave it in a tdb to
keep regedt32 from popping up an annoying dialog . */
lp_do_global_parameter ( lp_ctx , " registry:HKEY_USERS " , " hku.ldb " ) ;
2008-02-10 15:01:20 +03:00
2007-09-08 21:25:24 +04:00
/* using UTF8 by default allows us to support all chars */
lp_do_global_parameter ( lp_ctx , " unix charset " , " UTF8 " ) ;
/* Use codepage 850 as a default for the dos character set */
lp_do_global_parameter ( lp_ctx , " dos charset " , " CP850 " ) ;
/*
* Allow the default PASSWD_CHAT to be overridden in local . h .
*/
lp_do_global_parameter ( lp_ctx , " passwd chat " , DEFAULT_PASSWD_CHAT ) ;
lp_do_global_parameter ( lp_ctx , " pid directory " , dyn_PIDDIR ) ;
lp_do_global_parameter ( lp_ctx , " lock dir " , dyn_LOCKDIR ) ;
lp_do_global_parameter ( lp_ctx , " modules dir " , dyn_MODULESDIR ) ;
lp_do_global_parameter ( lp_ctx , " ncalrpc dir " , dyn_NCALRPCDIR ) ;
lp_do_global_parameter ( lp_ctx , " socket address " , " 0.0.0.0 " ) ;
2008-02-10 15:01:20 +03:00
lp_do_global_parameter_var ( lp_ctx , " server string " ,
2007-09-08 21:25:24 +04:00
" Samba %s " , SAMBA_VERSION_STRING ) ;
2008-02-10 15:01:20 +03:00
lp_do_global_parameter_var ( lp_ctx , " announce version " , " %d.%d " ,
2007-09-08 21:25:24 +04:00
DEFAULT_MAJOR_VERSION ,
DEFAULT_MINOR_VERSION ) ;
lp_do_global_parameter ( lp_ctx , " password server " , " * " ) ;
lp_do_global_parameter ( lp_ctx , " max mux " , " 50 " ) ;
lp_do_global_parameter ( lp_ctx , " max xmit " , " 12288 " ) ;
lp_do_global_parameter ( lp_ctx , " password level " , " 0 " ) ;
lp_do_global_parameter ( lp_ctx , " LargeReadwrite " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " server min protocol " , " CORE " ) ;
lp_do_global_parameter ( lp_ctx , " server max protocol " , " NT1 " ) ;
lp_do_global_parameter ( lp_ctx , " client min protocol " , " CORE " ) ;
lp_do_global_parameter ( lp_ctx , " client max protocol " , " NT1 " ) ;
lp_do_global_parameter ( lp_ctx , " security " , " USER " ) ;
lp_do_global_parameter ( lp_ctx , " paranoid server security " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " EncryptPasswords " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " ReadRaw " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " WriteRaw " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " NullPasswords " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " ObeyPamRestrictions " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " announce as " , " NT SERVER " ) ;
lp_do_global_parameter ( lp_ctx , " TimeServer " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " BindInterfacesOnly " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " Unicode " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " ClientLanManAuth " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " LanmanAuth " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " NTLMAuth " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " client use spnego principal " , " False " ) ;
2008-02-10 15:01:20 +03:00
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " UnixExtensions " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " PreferredMaster " , " Auto " ) ;
lp_do_global_parameter ( lp_ctx , " LocalMaster " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " wins support " , " False " ) ;
lp_do_global_parameter ( lp_ctx , " dns proxy " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " winbind separator " , " \\ " ) ;
lp_do_global_parameter ( lp_ctx , " winbind sealed pipes " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " winbindd socket directory " , dyn_WINBINDD_SOCKET_DIR ) ;
2008-06-28 16:02:19 +04:00
lp_do_global_parameter ( lp_ctx , " winbindd privileged socket directory " , dyn_WINBINDD_PRIVILEGED_SOCKET_DIR ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " template shell " , " /bin/false " ) ;
lp_do_global_parameter ( lp_ctx , " template homedir " , " /home/%WORKGROUP%/%ACCOUNTNAME% " ) ;
2008-02-17 22:25:13 +03:00
lp_do_global_parameter ( lp_ctx , " idmap trusted only " , " False " ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " client signing " , " Yes " ) ;
lp_do_global_parameter ( lp_ctx , " server signing " , " auto " ) ;
lp_do_global_parameter ( lp_ctx , " use spnego " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " smb ports " , " 445 139 " ) ;
lp_do_global_parameter ( lp_ctx , " nbt port " , " 137 " ) ;
lp_do_global_parameter ( lp_ctx , " dgram port " , " 138 " ) ;
lp_do_global_parameter ( lp_ctx , " cldap port " , " 389 " ) ;
lp_do_global_parameter ( lp_ctx , " krb5 port " , " 88 " ) ;
lp_do_global_parameter ( lp_ctx , " kpasswd port " , " 464 " ) ;
lp_do_global_parameter ( lp_ctx , " web port " , " 901 " ) ;
2007-09-10 07:44:47 +04:00
lp_do_global_parameter ( lp_ctx , " swat directory " , dyn_SWATDIR ) ;
2007-09-08 21:25:24 +04:00
lp_do_global_parameter ( lp_ctx , " nt status support " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " max wins ttl " , " 518400 " ) ; /* 6 days */
lp_do_global_parameter ( lp_ctx , " min wins ttl " , " 10 " ) ;
lp_do_global_parameter ( lp_ctx , " tls enabled " , " True " ) ;
lp_do_global_parameter ( lp_ctx , " tls keyfile " , " tls/key.pem " ) ;
lp_do_global_parameter ( lp_ctx , " tls certfile " , " tls/cert.pem " ) ;
lp_do_global_parameter ( lp_ctx , " tls cafile " , " tls/ca.pem " ) ;
2008-02-10 15:01:20 +03:00
lp_do_global_parameter_var ( lp_ctx , " setup directory " , " %s " ,
2007-09-08 21:25:24 +04:00
dyn_SETUPDIR ) ;
2008-02-04 09:59:16 +03:00
lp_do_global_parameter ( lp_ctx , " prefork children:smb " , " 4 " ) ;
2008-05-29 09:20:58 +04:00
lp_do_global_parameter ( lp_ctx , " ntp signd socket directory " , dyn_NTP_SIGND_SOCKET_DIR ) ;
2007-09-08 21:25:24 +04:00
for ( i = 0 ; parm_table [ i ] . label ; i + + ) {
2007-12-09 01:32:33 +03:00
if ( ! ( lp_ctx - > flags [ i ] & FLAG_CMDLINE ) ) {
lp_ctx - > flags [ i ] | = FLAG_DEFAULT ;
2007-09-08 21:25:24 +04:00
}
}
2007-12-09 01:31:41 +03:00
return lp_ctx ;
2007-09-08 21:25:24 +04:00
}
2007-12-09 01:32:37 +03:00
const char * lp_configfile ( struct loadparm_context * lp_ctx )
{
return lp_ctx - > szConfigFile ;
}
2007-12-30 03:14:12 +03:00
bool lp_load_default ( struct loadparm_context * lp_ctx )
{
return lp_load ( lp_ctx , dyn_CONFIGFILE ) ;
}
2007-12-09 01:32:27 +03:00
/**
2008-02-10 15:01:20 +03:00
* Load the services array from the services file .
2007-12-09 01:32:27 +03:00
*
* Return True on success , False on failure .
*/
2007-12-09 01:32:37 +03:00
bool lp_load ( struct loadparm_context * lp_ctx , const char * filename )
2003-08-13 05:53:07 +04:00
{
2007-09-08 03:37:00 +04:00
char * n2 ;
2007-09-08 04:07:50 +04:00
bool bRetval ;
2003-08-13 05:53:07 +04:00
2007-12-09 01:31:41 +03:00
filename = talloc_strdup ( lp_ctx , filename ) ;
2007-09-28 05:17:46 +04:00
2007-12-09 01:32:37 +03:00
lp_ctx - > szConfigFile = filename ;
2008-02-10 15:01:20 +03:00
2007-09-09 00:49:43 +04:00
lp_ctx - > bInGlobalSection = true ;
2007-12-09 01:32:37 +03:00
n2 = standard_sub_basic ( lp_ctx , lp_ctx - > szConfigFile ) ;
2005-07-20 14:07:48 +04:00
DEBUG ( 2 , ( " lp_load: refreshing parameters from %s \n " , n2 ) ) ;
2008-02-10 15:01:20 +03:00
2007-12-09 01:32:37 +03:00
add_to_file_list ( lp_ctx , lp_ctx - > szConfigFile , n2 ) ;
2005-07-20 14:07:48 +04:00
2003-08-13 05:53:07 +04:00
/* We get sections first, so have to start 'behind' to make up */
2007-09-09 00:49:43 +04:00
lp_ctx - > currentService = NULL ;
bRetval = pm_process ( n2 , do_section , do_parameter , lp_ctx ) ;
2003-08-13 05:53:07 +04:00
/* finish up the last section */
DEBUG ( 4 , ( " pm_process() returned %s \n " , BOOLSTR ( bRetval ) ) ) ;
if ( bRetval )
2007-09-09 00:49:43 +04:00
if ( lp_ctx - > currentService ! = NULL )
bRetval = service_ok ( lp_ctx - > currentService ) ;
2003-08-13 05:53:07 +04:00
2007-09-28 05:17:46 +04:00
lp_add_auto_services ( lp_ctx , lp_auto_services ( lp_ctx ) ) ;
2003-08-13 05:53:07 +04:00
2007-09-09 00:49:43 +04:00
lp_add_hidden ( lp_ctx , " IPC$ " , " IPC " ) ;
lp_add_hidden ( lp_ctx , " ADMIN$ " , " DISK " ) ;
2003-08-13 05:53:07 +04:00
2007-12-09 01:31:55 +03:00
if ( ! lp_ctx - > globals - > szWINSservers & & lp_ctx - > globals - > bWINSsupport ) {
2007-09-09 00:49:43 +04:00
lp_do_global_parameter ( lp_ctx , " wins server " , " 127.0.0.1 " ) ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:31:55 +03:00
panic_action = lp_ctx - > globals - > panic_action ;
2007-12-07 18:04:22 +03:00
2007-12-14 00:46:09 +03:00
reload_charcnv ( lp_ctx ) ;
2003-08-13 05:53:07 +04:00
2007-12-14 00:46:33 +03:00
/* FIXME: Check locale in environment for this: */
if ( strcmp ( lp_display_charset ( lp_ctx ) , lp_unix_charset ( lp_ctx ) ) ! = 0 )
2007-12-17 10:32:00 +03:00
d_set_iconv ( smb_iconv_open ( lp_display_charset ( lp_ctx ) , lp_unix_charset ( lp_ctx ) ) ) ;
2007-12-14 00:46:33 +03:00
else
d_set_iconv ( ( smb_iconv_t ) - 1 ) ;
2007-09-08 03:37:00 +04:00
return bRetval ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:27 +03:00
/**
* Return the max number of services .
*/
2003-08-13 05:53:07 +04:00
2007-09-27 23:49:53 +04:00
int lp_numservices ( struct loadparm_context * lp_ctx )
2003-08-13 05:53:07 +04:00
{
2007-09-27 23:49:53 +04:00
return lp_ctx - > iNumServices ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:27 +03:00
/**
* Display the contents of the services array in human - readable form .
*/
2003-08-13 05:53:07 +04:00
2008-02-10 15:01:20 +03:00
void lp_dump ( struct loadparm_context * lp_ctx , FILE * f , bool show_defaults ,
2007-09-27 23:49:53 +04:00
int maxtoprint )
2003-08-13 05:53:07 +04:00
{
int iService ;
if ( show_defaults )
2007-09-08 18:12:45 +04:00
defaults_saved = false ;
2003-08-13 05:53:07 +04:00
2007-09-28 03:31:28 +04:00
dump_globals ( lp_ctx , f , show_defaults ) ;
2003-08-13 05:53:07 +04:00
2008-02-28 22:04:58 +03:00
dump_a_service ( lp_ctx - > sDefault , lp_ctx - > sDefault , f ) ;
2003-08-13 05:53:07 +04:00
for ( iService = 0 ; iService < maxtoprint ; iService + + )
2008-02-28 22:04:58 +03:00
lp_dump_one ( f , show_defaults , lp_ctx - > services [ iService ] , lp_ctx - > sDefault ) ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:27 +03:00
/**
* Display the contents of one service in human - readable form .
*/
2008-02-28 22:04:58 +03:00
void lp_dump_one ( FILE * f , bool show_defaults , struct loadparm_service * service , struct loadparm_service * sDefault )
2003-08-13 05:53:07 +04:00
{
2007-09-08 20:46:30 +04:00
if ( service ! = NULL ) {
if ( service - > szService [ 0 ] = = ' \0 ' )
2003-08-13 05:53:07 +04:00
return ;
2008-02-28 22:04:58 +03:00
dump_a_service ( service , sDefault , f ) ;
2003-08-13 05:53:07 +04:00
}
}
2007-09-27 23:49:53 +04:00
struct loadparm_service * lp_servicebynum ( struct loadparm_context * lp_ctx ,
int snum )
2007-09-08 20:46:30 +04:00
{
2007-12-09 01:32:01 +03:00
return lp_ctx - > services [ snum ] ;
2007-09-08 20:46:30 +04:00
}
2008-02-10 15:01:20 +03:00
struct loadparm_service * lp_service ( struct loadparm_context * lp_ctx ,
2007-09-27 23:49:53 +04:00
const char * service_name )
2003-08-13 05:53:07 +04:00
{
int iService ;
2007-09-08 03:37:00 +04:00
char * serviceName ;
2007-12-17 13:12:36 +03:00
2007-09-27 23:49:53 +04:00
for ( iService = lp_ctx - > iNumServices - 1 ; iService > = 0 ; iService - - ) {
2008-02-10 15:01:20 +03:00
if ( lp_ctx - > services [ iService ] & &
2007-12-09 01:32:01 +03:00
lp_ctx - > services [ iService ] - > szService ) {
2003-08-13 05:53:07 +04:00
/*
* The substitution here is used to support % U is
* service names
*/
2007-09-24 22:47:50 +04:00
serviceName = standard_sub_basic (
2007-12-09 01:32:01 +03:00
lp_ctx - > services [ iService ] ,
lp_ctx - > services [ iService ] - > szService ) ;
2007-09-09 01:06:57 +04:00
if ( strequal ( serviceName , service_name ) )
2007-12-09 01:32:01 +03:00
return lp_ctx - > services [ iService ] ;
2003-08-13 05:53:07 +04:00
}
}
2007-09-09 01:06:57 +04:00
DEBUG ( 7 , ( " lp_servicenumber: couldn't find %s \n " , service_name ) ) ;
return NULL ;
2003-08-13 05:53:07 +04:00
}
2007-09-09 01:06:57 +04:00
2007-12-09 01:32:27 +03:00
/**
2008-02-10 15:01:20 +03:00
* A useful volume label function .
2007-12-09 01:32:27 +03:00
*/
2008-02-28 22:04:58 +03:00
const char * volume_label ( struct loadparm_service * service , struct loadparm_service * sDefault )
2003-08-13 05:53:07 +04:00
{
2008-02-28 22:04:58 +03:00
const char * ret = lp_volume ( service , sDefault ) ;
2003-08-13 05:53:07 +04:00
if ( ! * ret )
2007-09-08 20:46:30 +04:00
return lp_servicename ( service ) ;
2007-09-08 03:37:00 +04:00
return ret ;
2003-08-13 05:53:07 +04:00
}
2007-12-09 01:32:27 +03:00
/**
* If we are PDC then prefer us as DMB
*/
2008-02-28 22:04:58 +03:00
const char * lp_printername ( struct loadparm_service * service , struct loadparm_service * sDefault )
2003-08-13 05:53:07 +04:00
{
2008-02-28 22:04:58 +03:00
const char * ret = _lp_printername ( service , sDefault ) ;
2003-08-13 05:53:07 +04:00
if ( ret = = NULL | | ( ret ! = NULL & & * ret = = ' \0 ' ) )
2008-02-28 22:04:58 +03:00
ret = lp_servicename ( service ) ;
2003-08-13 05:53:07 +04:00
return ret ;
}
2007-12-09 01:32:27 +03:00
/**
* Return the max print jobs per queue .
*/
2008-02-28 22:04:58 +03:00
int lp_maxprintjobs ( struct loadparm_service * service , struct loadparm_service * sDefault )
2003-08-13 05:53:07 +04:00
{
2008-02-28 22:04:58 +03:00
int maxjobs = ( service ! = NULL ) ? service - > iMaxPrintJobs : sDefault - > iMaxPrintJobs ;
2003-08-13 05:53:07 +04:00
if ( maxjobs < = 0 | | maxjobs > = PRINT_MAX_JOBID )
maxjobs = PRINT_MAX_JOBID - 1 ;
return maxjobs ;
}
2007-12-14 00:46:09 +03:00
struct smb_iconv_convenience * lp_iconv_convenience ( struct loadparm_context * lp_ctx )
{
if ( lp_ctx = = NULL ) {
2007-12-16 00:23:45 +03:00
static struct smb_iconv_convenience * fallback_ic = NULL ;
if ( fallback_ic = = NULL )
fallback_ic = smb_iconv_convenience_init ( talloc_autofree_context ( ) ,
2007-12-14 00:46:33 +03:00
" CP850 " , " UTF8 " , true ) ;
2007-12-16 00:23:45 +03:00
return fallback_ic ;
2007-12-14 00:46:09 +03:00
}
return lp_ctx - > iconv_convenience ;
}
_PUBLIC_ void reload_charcnv ( struct loadparm_context * lp_ctx )
{
talloc_free ( lp_ctx - > iconv_convenience ) ;
lp_ctx - > iconv_convenience = smb_iconv_convenience_init_lp ( lp_ctx , lp_ctx ) ;
}
2008-01-04 02:22:12 +03:00
2008-02-10 15:01:20 +03:00
void lp_smbcli_options ( struct loadparm_context * lp_ctx ,
2008-01-04 02:22:12 +03:00
struct smbcli_options * options )
{
2008-02-10 15:01:20 +03:00
options - > max_xmit = lp_max_xmit ( lp_ctx ) ;
2008-01-04 02:22:12 +03:00
options - > max_mux = lp_maxmux ( lp_ctx ) ;
options - > use_spnego = lp_nt_status_support ( lp_ctx ) & & lp_use_spnego ( lp_ctx ) ;
options - > signing = lp_client_signing ( lp_ctx ) ;
options - > request_timeout = SMB_REQUEST_TIMEOUT ;
options - > ntstatus_support = lp_nt_status_support ( lp_ctx ) ;
options - > max_protocol = lp_cli_maxprotocol ( lp_ctx ) ;
options - > unicode = lp_unicode ( lp_ctx ) ;
2008-03-06 17:11:16 +03:00
options - > use_oplocks = true ;
options - > use_level2_oplocks = true ;
2008-01-04 02:22:12 +03:00
}
2008-09-30 03:29:53 +04:00
void lp_smbcli_session_options ( struct loadparm_context * lp_ctx ,
struct smbcli_session_options * options )
{
options - > lanman_auth = lp_client_lanman_auth ( lp_ctx ) ;
options - > ntlmv2_auth = lp_client_ntlmv2_auth ( lp_ctx ) ;
options - > plaintext_auth = lp_client_plaintext_auth ( lp_ctx ) ;
}