From: <ale...@us...> - 2013-04-04 13:18:04
|
Revision: 57896 http://sourceforge.net/p/firebird/code/57896 Author: alexpeshkoff Date: 2013-04-04 13:17:57 +0000 (Thu, 04 Apr 2013) Log Message: ----------- Added support for changing configuration (client and embedded) from API Modified Paths: -------------- firebird/trunk/builds/install/misc/firebird.conf.in firebird/trunk/src/auth/SecureRemotePassword/server/SrpServer.cpp firebird/trunk/src/common/call_service.cpp firebird/trunk/src/common/call_service.h firebird/trunk/src/common/config/config.cpp firebird/trunk/src/common/config/config.h firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp firebird/trunk/src/include/consts_pub.h firebird/trunk/src/include/firebird/Interface.h firebird/trunk/src/include/firebird.h firebird/trunk/src/jrd/EngineInterface.h firebird/trunk/src/jrd/jrd.cpp firebird/trunk/src/jrd/svc.cpp firebird/trunk/src/remote/client/interface.cpp firebird/trunk/src/remote/inet.cpp firebird/trunk/src/remote/inet_proto.h firebird/trunk/src/remote/os/win32/wnet.cpp firebird/trunk/src/remote/os/win32/wnet_proto.h firebird/trunk/src/remote/os/win32/xnet.cpp firebird/trunk/src/remote/os/win32/xnet_proto.h firebird/trunk/src/remote/remot_proto.h firebird/trunk/src/remote/remote.cpp firebird/trunk/src/remote/remote.h firebird/trunk/src/remote/server/os/posix/inet_server.cpp firebird/trunk/src/remote/server/server.cpp firebird/trunk/src/utilities/gsec/gsec.cpp firebird/trunk/src/yvalve/MasterImplementation.cpp firebird/trunk/src/yvalve/MasterImplementation.h firebird/trunk/src/yvalve/why.cpp Modified: firebird/trunk/builds/install/misc/firebird.conf.in =================================================================== --- firebird/trunk/builds/install/misc/firebird.conf.in 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/builds/install/misc/firebird.conf.in 2013-04-04 13:17:57 UTC (rev 57896) @@ -19,9 +19,9 @@ # To activate an entry, remove the leading "#"s and supply the desired # value. # -# Please note, a number of the values are specified in **Bytes** (Not KB). -# Accordingly, we have provided some simple conversion tables at the bottom -# of this file. +# Please note, by default a number of the values are specified in **Bytes** (Not KB). +# You may add obvious abbreviations k, m and g in the end of a numver to specify +# kilobytes, megabytes and gigabytes. # # There are three types of configuration values: integer, boolean and string. # @@ -31,12 +31,13 @@ # 1 # 42 # 4711 +# 24M # 24 * 1024 * 1024 # # Boolean # ------- # Boolean is expressed as integer values with 0 (zero) being "false" and # non-zero is taken to mean "true". For consistency we recommend you -# only use 0/1. +# only use 0/1. Also strings 'y', 'yes' and 'true' stand for "true". # # String # ------ @@ -44,6 +45,14 @@ # RemoteServiceName = gds_db # RemotePipeName = pipe47 # +# Scopes +# ------ +# Some parameters are marked as per-database / per-connection configurable. +# Per-database configuration is done in file databases.conf (former aliases.conf). +# Per-connection configuration is primarily client tool and done using +# isc_dpb_config parameter in DPB (isc_spb_config for services). +# Notice that per-database entries also may be tuned using DPB in case of +# embedded engine when attaching to database first time. # # Portions of this file have been reproduced/made available with the # permission of Ann Harrison @ IBPhoenix. @@ -350,12 +359,16 @@ # is default one. On windows Sspi is also used when no login/password is given. # Client can use legacy authentication to talk to old servers. # +# Per-database & per-connection configurable. +# #AuthServer = Srp, Win_Sspi #AuthClient = Srp, Win_Sspi, Legacy_Auth # UserManager sets plugin used to work with security database. If more than # one plugin is given, first plugin from the list is used. # +# Per-database configurable. +# #UserManager = Srp # TracePlugin is used by firebird trace facility to send trace data to the user @@ -366,10 +379,14 @@ # Crypt plugins are used to crypt data transferred over the wire. # In default case wire is encrypted using Alleged RC4 # (key must be generated by auth plugin). +# +# Per-connection configurable. +# #CryptPlugin = Arc4 # Key holder is a kind of temp storage for DB crypt keys. # There is no default for this kind of plugins. +# #KeyHolderPlugin = @@ -381,6 +398,8 @@ # # Type: string # +# Per-database & per-connection configurable. +# #Providers = Remote,Engine12,Loopback @@ -475,11 +494,28 @@ # # Seconds to wait before concluding an attempt to connect has failed. # +# Per-connection configurable. +# # Type: integer # #ConnectionTimeout = 180 # +# Should connection over the wire be encrypted? +# Has 3 different values: Required, Enabled or Disabled. Enabled behavior +# depends another side requirements. If both sides set to enabled, connection +# is encrypted. +# +# Attention: default depends upon connection type: incoming (server) +# or outgoing (client). +# +# Per-connection configurable. +# +# Type: integer +# +#WireCrypt = Enabled (for client) / Required (for server) + +# # Seconds to wait on a silent client connection before the server sends # dummy packets to request acknowledgment. # @@ -495,6 +531,8 @@ # follow instrutions of this article: # http://support.microsoft.com/default.aspx?kbid=140325 # +# Per-connection configurable. +# # Type: integer # #DummyPacketInterval = 0 @@ -510,6 +548,8 @@ # order of precendence is the 'RemoteServiceName' (if an entry is # found in the 'services.' file) then the 'RemoteServicePort'. # +# Per-connection configurable. +# # Type: string, integer # #RemoteServiceName = gds_db @@ -520,6 +560,8 @@ # messages. The value of 0 (Zero) means that the server will choose # a port number randomly. # +# Per-connection configurable. +# # Type: integer # #RemoteAuxPort = 0 @@ -540,6 +582,8 @@ # # Note: Currently is a default for classic and super servers. # +# Per-connection configurable. +# # Type: boolean # #TcpNoNagle = 1 @@ -701,6 +745,8 @@ # Windows Vista/XP SP2/2000 SP4 it will not be accessible using the # local protocol from other sessions. # +# Per-connection configurable. +# # Type: string # #IpcName = FIREBIRD @@ -710,6 +756,8 @@ # Has the same meaning as a port number for TCP/IP. The default value is # compatible with IB/FB1. # +# Per-connection configurable. +# # Type: string # #RemotePipeName = interbas Modified: firebird/trunk/src/auth/SecureRemotePassword/server/SrpServer.cpp =================================================================== --- firebird/trunk/src/auth/SecureRemotePassword/server/SrpServer.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/auth/SecureRemotePassword/server/SrpServer.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -32,6 +32,8 @@ #include "../common/classes/ClumpletWriter.h" #include "../auth/SecureRemotePassword/Message.h" +#include "../jrd/EngineInterface.h" + using namespace Firebird; namespace { @@ -122,6 +124,8 @@ dpb.insertByte(isc_dpb_sec_attach, TRUE); const char* str = "SYSDBA"; dpb.insertString(isc_dpb_user_name, str, strlen(str)); + const char* providers = "Providers=" CURRENT_ENGINE; + dpb.insertString(isc_dpb_config, providers, strlen(providers)); DispatcherPtr p; Modified: firebird/trunk/src/common/call_service.cpp =================================================================== --- firebird/trunk/src/common/call_service.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/common/call_service.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -28,6 +28,7 @@ #include <stdio.h> #include <ctype.h> #include "../common/utils_proto.h" +#include "../jrd/EngineInterface.h" using namespace Firebird; @@ -196,7 +197,7 @@ return 0; } - return attachRemoteServiceManager(status, username, password, trusted, service); + return attachRemoteServiceManager(status, username, password, trusted, service, true); } @@ -218,7 +219,8 @@ const TEXT* username, const TEXT* password, bool trusted, - const TEXT* server) + const TEXT* server, + bool forceLoopback) { char service[SERVICE_SIZE]; @@ -242,6 +244,10 @@ { stuffSpb(spb, isc_spb_trusted_auth, ""); } + if ((!server[0]) && forceLoopback && (!Config::getSharedDatabase())) + { // local connection & force & superserver + stuffSpb(spb, isc_spb_config, "Providers=Loopback," CURRENT_ENGINE); + } fb_assert((size_t)(spb - spb_buffer) <= sizeof(spb_buffer)); isc_svc_handle svc_handle = 0; Modified: firebird/trunk/src/common/call_service.h =================================================================== --- firebird/trunk/src/common/call_service.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/common/call_service.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -30,7 +30,7 @@ isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, bool, int, const TEXT*); -isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, bool, const TEXT*); +isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, bool, const TEXT*, bool); void callRemoteServiceManager(ISC_STATUS*, isc_svc_handle, Auth::UserData&, Auth::IListUsers*); void detachRemoteServiceManager(ISC_STATUS*, isc_svc_handle); Modified: firebird/trunk/src/common/config/config.cpp =================================================================== --- firebird/trunk/src/common/config/config.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/common/config/config.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -28,6 +28,7 @@ #include "../common/classes/init.h" #include "../common/dllinst.h" #include "../common/os/fbsyslog.h" +#include "../jrd/EngineInterface.h" #include "firebird/Plugin.h" #ifdef HAVE_STDLIB_H @@ -72,7 +73,7 @@ defaultConfig = newConfig; } */ - Firebird::RefPtr<Config> getDefaultConfig() const + const Firebird::RefPtr<Config>& getDefaultConfig() const { return defaultConfig; } @@ -176,7 +177,7 @@ {TYPE_STRING, "AuditTraceConfigFile", (ConfigValue) ""}, // location of audit trace configuration file {TYPE_INTEGER, "MaxUserTraceLogSize", (ConfigValue) 10}, // maximum size of user session trace log {TYPE_INTEGER, "FileSystemCacheSize", (ConfigValue) 0}, // percent - {TYPE_STRING, "Providers", (ConfigValue) "Remote, Engine12, Loopback"}, + {TYPE_STRING, "Providers", (ConfigValue) "Remote, " CURRENT_ENGINE ", Loopback"}, {TYPE_STRING, "AuthServer", (ConfigValue) "Srp, Win_Sspi"}, {TYPE_STRING, "AuthClient", (ConfigValue) "Srp, Win_Sspi, Legacy_Auth"}, {TYPE_STRING, "UserManager", (ConfigValue) "Srp"}, @@ -197,7 +198,7 @@ Config::Config(const ConfigFile& file) { // Array to save string temporarily - // Will be finally save by loadValues() in the end of ctor + // Will be finally saved by loadValues() in the end of ctor Firebird::ObjectsArray<ConfigFile::String> tempStrings(getPool()); // Iterate through the known configuration entries @@ -231,6 +232,15 @@ loadValues(file); } +void Config::merge(Firebird::RefPtr<Config>& config, const Firebird::string* dpbConfig) +{ + if (dpbConfig && dpbConfig->hasData()) + { + ConfigFile txtStream(ConfigFile::USE_TEXT, dpbConfig->c_str()); + config = new Config(txtStream, *(config.hasData() ? config : getDefaultConfig())); + } +} + void Config::loadValues(const ConfigFile& file) { // Iterate through the known configuration entries @@ -296,7 +306,7 @@ * Public interface */ -const Firebird::RefPtr<Config> Config::getDefaultConfig() +const Firebird::RefPtr<Config>& Config::getDefaultConfig() { return firebirdConf().getDefaultConfig(); } @@ -413,9 +423,9 @@ return rc; } -bool Config::getTcpNoNagle() +bool Config::getTcpNoNagle() const { - return (bool) getDefaultConfig()->values[KEY_TCP_NO_NAGLE]; + return get<bool>(KEY_TCP_NO_NAGLE); } int Config::getDefaultDbCachePages() const @@ -428,14 +438,14 @@ return rc; } -int Config::getConnectionTimeout() +int Config::getConnectionTimeout() const { - return (int) getDefaultConfig()->values[KEY_CONNECTION_TIMEOUT]; + return get<int>(KEY_CONNECTION_TIMEOUT); } -int Config::getDummyPacketInterval() +int Config::getDummyPacketInterval() const { - return (int) getDefaultConfig()->values[KEY_DUMMY_PACKET_INTERVAL]; + return get<int>(KEY_DUMMY_PACKET_INTERVAL); } int Config::getLockMemSize() const @@ -463,24 +473,24 @@ return get<int>(KEY_DEADLOCK_TIMEOUT); } -const char *Config::getRemoteServiceName() +const char *Config::getRemoteServiceName() const { - return (const char*) getDefaultConfig()->values[KEY_REMOTE_SERVICE_NAME]; + return get<const char*>(KEY_REMOTE_SERVICE_NAME); } -unsigned short Config::getRemoteServicePort() +unsigned short Config::getRemoteServicePort() const { - return (unsigned short) getDefaultConfig()->values[KEY_REMOTE_SERVICE_PORT]; + return get<unsigned short>(KEY_REMOTE_SERVICE_PORT); } -const char *Config::getRemotePipeName() +const char *Config::getRemotePipeName() const { - return (const char*) getDefaultConfig()->values[KEY_REMOTE_PIPE_NAME]; + return get<const char*>(KEY_REMOTE_PIPE_NAME); } -const char *Config::getIpcName() +const char *Config::getIpcName() const { - return (const char*) getDefaultConfig()->values[KEY_IPC_NAME]; + return get<const char*>(KEY_IPC_NAME); } int Config::getMaxUnflushedWrites() const @@ -498,9 +508,9 @@ return (int) getDefaultConfig()->values[KEY_PROCESS_PRIORITY_LEVEL]; } -int Config::getRemoteAuxPort() +int Config::getRemoteAuxPort() const { - return (int) getDefaultConfig()->values[KEY_REMOTE_AUX_PORT]; + return get<int>(KEY_REMOTE_AUX_PORT); } const char *Config::getRemoteBindAddress() @@ -644,17 +654,6 @@ return (bool) getDefaultConfig()->values[KEY_SHARED_DATABASE]; } -bool Config::getMultiClientServer() -{ - // AP - absolutely wrong for superclassic assumption - // should be set by server in case of 'super' mode in it -#ifdef SUPERSERVER - return true; -#else - return false; -#endif -} - const char* Config::getPlugins(unsigned int type) const { switch (type) @@ -715,8 +714,8 @@ return get<const char*>(KEY_SECURITY_DATABASE); } -const char* Config::getWireCrypt(WireCryptMode wcMode) +const char* Config::getWireCrypt(WireCryptMode wcMode) const { - const char* rc = getDefaultConfig()->get<const char*>(KEY_WIRE_CRYPT); + const char* rc = get<const char*>(KEY_WIRE_CRYPT); return rc ? rc : wcMode == WC_CLIENT ? WIRE_CRYPT_ENABLED : WIRE_CRYPT_REQUIRED; } Modified: firebird/trunk/src/common/config/config.h =================================================================== --- firebird/trunk/src/common/config/config.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/common/config/config.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -192,8 +192,11 @@ static const Firebird::PathName* getCommandLineRootDirectory(); // Master config - needed to provide per-database config - static const Firebird::RefPtr<Config> getDefaultConfig(); + static const Firebird::RefPtr<Config>& getDefaultConfig(); + // Merge config entries from DPB into existing config + static void merge(Firebird::RefPtr<Config>& config, const Firebird::string* dpbConfig); + // reports key to be used by the following functions static unsigned int getKeyByName(ConfigName name); // helpers to build interface for firebird.conf file @@ -229,16 +232,16 @@ static int getTcpRemoteBufferSize(); // Disable Nagle algorithm - static bool getTcpNoNagle(); + bool getTcpNoNagle() const; // Default database cache size int getDefaultDbCachePages() const; // Connection timeout - static int getConnectionTimeout(); + int getConnectionTimeout() const; // Dummy packet interval - static int getDummyPacketInterval(); + int getDummyPacketInterval() const; // Lock manager memory size int getLockMemSize() const; @@ -256,16 +259,16 @@ int getDeadlockTimeout() const; // Service name for remote protocols - static const char* getRemoteServiceName(); + const char* getRemoteServiceName() const; // Service port for INET - static unsigned short getRemoteServicePort(); + unsigned short getRemoteServicePort() const; // Pipe name for WNET - static const char* getRemotePipeName(); + const char* getRemotePipeName() const; // Name for IPC-related objects - static const char* getIpcName(); + const char* getIpcName() const; // Unflushed writes number int getMaxUnflushedWrites() const; @@ -277,7 +280,7 @@ static int getProcessPriorityLevel(); // Port for event processing - static int getRemoteAuxPort(); + int getRemoteAuxPort() const; // Server binding NIC address static const char* getRemoteBindAddress(); @@ -328,13 +331,11 @@ static bool getSharedDatabase(); - static bool getMultiClientServer(); - const char* getPlugins(unsigned int type) const; const char* getSecurityDatabase() const; - static const char* getWireCrypt(WireCryptMode wcMode); + const char* getWireCrypt(WireCryptMode wcMode) const; }; // Implementation of interface to access master configuration file Modified: firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp =================================================================== --- firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -760,6 +760,11 @@ { return NULL; } + + virtual int FB_CARG serverMode(int mode) + { + return -1; + } }; Modified: firebird/trunk/src/include/consts_pub.h =================================================================== --- firebird/trunk/src/include/consts_pub.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/include/consts_pub.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -119,6 +119,7 @@ #define isc_dpb_specific_auth_data 84 #define isc_dpb_auth_plugin_list 85 #define isc_dpb_auth_plugin_name 86 +#define isc_dpb_config 87 /**************************************************/ /* clumplet tags used inside isc_dpb_address_path */ @@ -280,6 +281,7 @@ #define isc_spb_remote_protocol 120 #define isc_spb_host_name 121 #define isc_spb_os_user 122 +#define isc_spb_config 123 #define isc_spb_connect_timeout isc_dpb_connect_timeout #define isc_spb_dummy_packet_interval isc_dpb_dummy_packet_interval Modified: firebird/trunk/src/include/firebird/Interface.h =================================================================== --- firebird/trunk/src/include/firebird/Interface.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/include/firebird/Interface.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -121,8 +121,9 @@ virtual IMetadataBuilder* FB_CARG getMetadataBuilder(IStatus* status, unsigned fieldCount) = 0; virtual Firebird::IDebug* FB_CARG getDebug() = 0; + virtual int FB_CARG serverMode(int mode) = 0; }; -#define FB_MASTER_VERSION (FB_VERSIONED_VERSION + 12) +#define FB_MASTER_VERSION (FB_VERSIONED_VERSION + 13) } // namespace Firebird Modified: firebird/trunk/src/include/firebird.h =================================================================== --- firebird/trunk/src/include/firebird.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/include/firebird.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -75,8 +75,4 @@ #define TRUSTED_AUTH #endif -#if defined(SUPERSERVER) -#define SHARED_METADATA_CACHE -#endif - #endif // INCLUDE_Firebird_H Modified: firebird/trunk/src/jrd/EngineInterface.h =================================================================== --- firebird/trunk/src/jrd/EngineInterface.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/jrd/EngineInterface.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -28,6 +28,8 @@ #include "../common/StatementMetadata.h" #include "../common/classes/RefCounted.h" +#define CURRENT_ENGINE "Engine12" + namespace Jrd { // Engine objects used by interface objects Modified: firebird/trunk/src/jrd/jrd.cpp =================================================================== --- firebird/trunk/src/jrd/jrd.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/jrd/jrd.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -355,7 +355,7 @@ void registerEngine(IPluginManager* iPlugin) { myModule->setCleanup(shutdownBeforeUnload); - iPlugin->registerPluginFactory(PluginType::Provider, "Engine12", &engineFactory); + iPlugin->registerPluginFactory(PluginType::Provider, CURRENT_ENGINE, &engineFactory); myModule->registerMe(); } @@ -739,6 +739,7 @@ string dpb_trusted_login; PathName dpb_remote_process; PathName dpb_org_filename; + string dpb_config; public: DatabaseOptions() @@ -1281,12 +1282,10 @@ if (options.dpb_set_page_buffers) { -#ifdef SHARED_METADATA_CACHE // Here we do not let anyone except SYSDBA (like DBO) to change dbb_page_buffers, // cause other flags is UserId can be set only when DB is opened. // No idea how to test for other cases before init is complete. - if (userId.locksmith()) -#endif + if (config->getSharedDatabase() ? userId.locksmith() : true) dbb->dbb_page_buffers = options.dpb_page_buffers; } @@ -5585,6 +5584,10 @@ ERR_post(Arg::Gds(isc_exec_sql_max_call_exceeded)); break; + case isc_dpb_config: + getString(rdr, dpb_config); + break; + default: break; } @@ -5681,6 +5684,13 @@ tdbb->setDatabase(dbb); jAtt = create_attachment(alias_name, dbb, options); tdbb->setAttachment(jAtt->getHandle()); + + if (options.dpb_config.hasData()) + { + ERR_post_warning(Arg::Warning(isc_random) << + "Secondary attachment - config data from DPB ignored"); + } + return jAtt; } @@ -5690,6 +5700,8 @@ } } + Config::merge(config, &options.dpb_config); + dbb = Database::create(); dbb->dbb_config = config; dbb->dbb_filename = expanded_name; Modified: firebird/trunk/src/jrd/svc.cpp =================================================================== --- firebird/trunk/src/jrd/svc.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/jrd/svc.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -60,6 +60,7 @@ #include "../jrd/msg_encode.h" #include "../jrd/trace/TraceManager.h" #include "../jrd/trace/TraceObjects.h" +#include "../jrd/EngineInterface.h" #include "../common/classes/DbImplementation.h" @@ -637,6 +638,8 @@ void Service::fillDpb(ClumpletWriter& dpb) { + const char* providers = "Providers=" CURRENT_ENGINE; + dpb.insertString(isc_dpb_config, providers, strlen(providers)); if (svc_address_path.hasData()) { dpb.insertString(isc_dpb_address_path, svc_address_path); @@ -684,14 +687,19 @@ val |= QUOTED_FILENAME_SUPPORT; #endif // WIN_NT - if (Config::getMultiClientServer()) + Firebird::MasterInterfacePtr master; + switch (master->serverMode(-1)) { + case 1: // super val |= MULTI_CLIENT_SUPPORT; - } - else - { + break; + case 0: // classic val |= NO_SERVER_SHUTDOWN_SUPPORT; + break; + default: // none-server mode + break; } + return val; } } Modified: firebird/trunk/src/remote/client/interface.cpp =================================================================== --- firebird/trunk/src/remote/client/interface.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/client/interface.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -650,7 +650,7 @@ static void add_other_params(rem_port*, ClumpletWriter&, const ParametersSet&); static void add_working_directory(ClumpletWriter&, const PathName&); static rem_port* analyze(ClntAuthBlock&, PathName&, bool, ClumpletReader&, PathName&, bool); -static rem_port* analyze_service(PathName&, bool, ClumpletReader&, bool); +static rem_port* analyze_service(ClntAuthBlock&, PathName&, bool, ClumpletReader&, bool); static void batch_gds_receive(rem_port*, struct rmtque *, USHORT); static void batch_dsql_fetch(rem_port*, struct rmtque *, USHORT); static void clear_queue(rem_port*); @@ -746,7 +746,7 @@ PathName expanded_name(filename); PathName node_name; - ClntAuthBlock cBlock(&expanded_name); + ClntAuthBlock cBlock(&expanded_name, &newDpb, &dpbParam); rem_port* port = analyze(cBlock, expanded_name, user_verification, newDpb, node_name, loopback); if (!port) @@ -1322,7 +1322,7 @@ PathName expanded_name(filename); PathName node_name; - ClntAuthBlock cBlock(&expanded_name); + ClntAuthBlock cBlock(&expanded_name, &newDpb, &dpbParam); rem_port* port = analyze(cBlock, expanded_name, user_verification, newDpb, node_name, loopback); if (!port) @@ -4375,7 +4375,9 @@ ClumpletWriter newSpb(ClumpletReader::spbList, MAX_DPB_SIZE, spb, spbLength); const bool user_verification = get_new_dpb(newSpb, spbParam); - rem_port* port = analyze_service(expanded_name, user_verification, newSpb, loopback); + ClntAuthBlock cBlock(NULL, &newSpb, &spbParam); + cBlock.loadClnt(newSpb, &spbParam); + rem_port* port = analyze_service(cBlock, expanded_name, user_verification, newSpb, loopback); RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION); Rdb* rdb = port->port_context; @@ -4386,8 +4388,6 @@ add_other_params(port, newSpb, spbParam); - ClntAuthBlock cBlock(NULL); - cBlock.load(newSpb, &spbParam); IntlSpb intl; init(status, cBlock, port, op_service_attach, expanded_name, newSpb, intl, cryptCallback); @@ -4528,7 +4528,7 @@ rem_port* port = rdb->rdb_port; RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION); - ClntAuthBlock cBlock(NULL); + ClntAuthBlock cBlock(NULL, NULL, NULL); cBlock.loadServiceDataFrom(port); info(status, rdb, op_service_info, rdb->rdb_id, 0, @@ -5146,7 +5146,7 @@ // Analyze the file name to see if a remote connection is required. If not, // quietly (sic) return. - cBlock.load(dpb, &dpbParam); + cBlock.loadClnt(dpb, &dpbParam); authenticateStep0(cBlock); rem_port* port = NULL; @@ -5154,7 +5154,7 @@ #ifdef WIN_NT if (ISC_analyze_protocol(PROTOCOL_XNET, file_name, node_name)) { - port = XNET_analyze(&cBlock, file_name, uv_flag); + port = XNET_analyze(&cBlock, file_name, uv_flag, cBlock.getConfig()); } else if (ISC_analyze_protocol(PROTOCOL_WNET, file_name, node_name) || ISC_analyze_pclan(file_name, node_name)) @@ -5167,7 +5167,7 @@ ISC_utf8ToSystem(node_name); } - port = WNET_analyze(&cBlock, file_name, node_name.c_str(), uv_flag); + port = WNET_analyze(&cBlock, file_name, node_name.c_str(), uv_flag, cBlock.getConfig()); } else #endif @@ -5183,7 +5183,7 @@ ISC_utf8ToSystem(node_name); } - port = INET_analyze(&cBlock, file_name, node_name.c_str(), uv_flag, dpb); + port = INET_analyze(&cBlock, file_name, node_name.c_str(), uv_flag, dpb, cBlock.getConfig()); } // We have a local connection string. If it's a file on a network share, @@ -5197,7 +5197,7 @@ ISC_unescape(node_name); ISC_utf8ToSystem(node_name); - port = WNET_analyze(&cBlock, expanded_name, node_name.c_str(), uv_flag); + port = WNET_analyze(&cBlock, expanded_name, node_name.c_str(), uv_flag, cBlock.getConfig()); } #endif @@ -5210,7 +5210,7 @@ ISC_unescape(node_name); ISC_utf8ToSystem(node_name); - port = INET_analyze(&cBlock, expanded_name, node_name.c_str(), uv_flag, dpb); + port = INET_analyze(&cBlock, expanded_name, node_name.c_str(), uv_flag, dpb, cBlock.getConfig()); } } #endif @@ -5225,17 +5225,17 @@ #ifdef WIN_NT if (!port) { - port = XNET_analyze(&cBlock, file_name, uv_flag); + port = XNET_analyze(&cBlock, file_name, uv_flag, cBlock.getConfig()); } if (!port) { - port = WNET_analyze(&cBlock, file_name, WNET_LOCALHOST, uv_flag); + port = WNET_analyze(&cBlock, file_name, WNET_LOCALHOST, uv_flag, cBlock.getConfig()); } #endif if (!port) { - port = INET_analyze(&cBlock, file_name, INET_LOCALHOST, uv_flag, dpb); + port = INET_analyze(&cBlock, file_name, INET_LOCALHOST, uv_flag, dpb, cBlock.getConfig()); } } } @@ -5244,7 +5244,8 @@ } -static rem_port* analyze_service(PathName& service_name, +static rem_port* analyze_service(ClntAuthBlock& cBlock, + PathName& service_name, bool uv_flag, ClumpletReader& spb, bool loopback) @@ -5272,7 +5273,7 @@ #if defined(WIN_NT) if (ISC_analyze_protocol(PROTOCOL_XNET, service_name, node_name)) { - return XNET_analyze(NULL, service_name, uv_flag); + return XNET_analyze(NULL, service_name, uv_flag, cBlock.getConfig()); } if (ISC_analyze_protocol(PROTOCOL_WNET, service_name, node_name) || @@ -5282,7 +5283,7 @@ { node_name = WNET_LOCALHOST; } - return WNET_analyze(NULL, service_name, node_name.c_str(), uv_flag); + return WNET_analyze(NULL, service_name, node_name.c_str(), uv_flag, cBlock.getConfig()); } #endif @@ -5293,7 +5294,7 @@ { node_name = INET_LOCALHOST; } - return INET_analyze(NULL, service_name, node_name.c_str(), uv_flag, spb); + return INET_analyze(NULL, service_name, node_name.c_str(), uv_flag, spb, cBlock.getConfig()); } rem_port* port = NULL; @@ -5309,17 +5310,17 @@ #if defined(WIN_NT) if (!port) { - port = XNET_analyze(NULL, service_name, uv_flag); + port = XNET_analyze(NULL, service_name, uv_flag, cBlock.getConfig()); } if (!port) { - port = WNET_analyze(NULL, service_name, WNET_LOCALHOST, uv_flag); + port = WNET_analyze(NULL, service_name, WNET_LOCALHOST, uv_flag, cBlock.getConfig()); } #endif if (!port) { - port = INET_analyze(NULL, service_name, INET_LOCALHOST, uv_flag, spb); + port = INET_analyze(NULL, service_name, INET_LOCALHOST, uv_flag, spb, cBlock.getConfig()); } } } @@ -7102,7 +7103,7 @@ IntlSpbStart().fromUtf8(send, 0); } - ClntAuthBlock cBlock(NULL); + ClntAuthBlock cBlock(NULL, NULL, NULL); cBlock.loadServiceDataFrom(rdb->rdb_port); HANDSHAKE_DEBUG(fprintf(stderr, "start calls authFillParametersBlock\n")); authFillParametersBlock(cBlock, send, &spbStartParam, rdb->rdb_port); @@ -7249,14 +7250,19 @@ } //namespace Remote -ClntAuthBlock::ClntAuthBlock(const Firebird::PathName* fileName) +ClntAuthBlock::ClntAuthBlock(const Firebird::PathName* fileName, Firebird::ClumpletReader* dpb, + const ParametersSet* tags) : pluginList(getPool()), userName(getPool()), password(getPool()), dataForPlugin(getPool()), dataFromPlugin(getPool()), - hasCryptKey(false), + cryptKeys(getPool()), dpbConfig(getPool()), hasCryptKey(false), plugins(PluginType::AuthClient, FB_AUTH_CLIENT_VERSION, upInfo), authComplete(false), firstTime(true) { - reset(fileName); + if (dpb && tags && dpb->find(tags->config_text)) + { + dpb->getString(dpbConfig); + } + resetClnt(fileName); } void ClntAuthBlock::resetDataFromPlugin() @@ -7317,7 +7323,7 @@ ISC_unescape(s); } -void ClntAuthBlock::load(Firebird::ClumpletReader& dpb, const ParametersSet* tags) +void ClntAuthBlock::loadClnt(Firebird::ClumpletReader& dpb, const ParametersSet* tags) { bool uft8Convert = !dpb.find(isc_dpb_utf8_filename); Modified: firebird/trunk/src/remote/inet.cpp =================================================================== --- firebird/trunk/src/remote/inet.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/inet.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -447,7 +447,8 @@ Rdb*, const PathName&, const TEXT*, - ClumpletReader&); + ClumpletReader&, + RefPtr<Config>*); static bool_t inet_write(XDR*); //, int); #ifdef DEBUG @@ -521,7 +522,8 @@ const PathName& file_name, const TEXT* node_name, bool uv_flag, - ClumpletReader &dpb) + ClumpletReader &dpb, + RefPtr<Config>* config) { /************************************** * @@ -604,7 +606,7 @@ // Try connection using first set of protocols - rem_port* port = inet_try_connect(packet, rdb, file_name, node_name, dpb); + rem_port* port = inet_try_connect(packet, rdb, file_name, node_name, dpb, config); P_ACPT* accept = NULL; switch (packet->p_operation) @@ -623,7 +625,7 @@ case op_accept: if (cBlock) { - cBlock->reset(&file_name); + cBlock->resetClnt(&file_name); } accept = &packet->p_acpt; break; @@ -678,7 +680,8 @@ rem_port* INET_connect(const TEXT* name, PACKET* packet, USHORT flag, - ClumpletReader* dpb) + ClumpletReader* dpb, + RefPtr<Config>* config) { /************************************** * @@ -709,6 +712,10 @@ #endif rem_port* const port = alloc_port(NULL); + if (config) + { + port->port_config = *config; + } REMOTE_get_timeout_params(port, dpb); string host; @@ -736,12 +743,12 @@ if (protocol.isEmpty()) { - const unsigned short port2 = Config::getRemoteServicePort(); + const unsigned short port2 = port->getPortConfig()->getRemoteServicePort(); if (port2) { protocol.printf("%hu", port2); } else { - protocol = Config::getRemoteServiceName(); + protocol = port->getPortConfig()->getRemoteServiceName(); } } @@ -1462,7 +1469,7 @@ address.sin_family = AF_INET; in_addr bind_addr = get_bind_address(); memcpy(&address.sin_addr, &bind_addr, sizeof(address.sin_addr)); - address.sin_port = htons(Config::getRemoteAuxPort()); + address.sin_port = htons(port->getPortConfig()->getRemoteAuxPort()); SOCKET n = socket(AF_INET, SOCK_STREAM, 0); if (n == INVALID_SOCKET) @@ -2672,7 +2679,8 @@ Rdb* rdb, const PathName& file_name, const TEXT* node_name, - ClumpletReader& dpb) + ClumpletReader& dpb, + RefPtr<Config>* config) { /************************************** * @@ -2702,7 +2710,7 @@ rem_port* port = NULL; try { - port = INET_connect(node_name, packet, FALSE, &dpb); + port = INET_connect(node_name, packet, FALSE, &dpb, config); } catch (const Exception&) { @@ -3203,7 +3211,7 @@ * in case of unexpected error * **************************************/ - if (Config::getTcpNoNagle()) + if (port->getPortConfig()->getTcpNoNagle()) { int optval = TRUE; int n = setsockopt(port->port_handle, IPPROTO_TCP, TCP_NODELAY, Modified: firebird/trunk/src/remote/inet_proto.h =================================================================== --- firebird/trunk/src/remote/inet_proto.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/inet_proto.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -25,6 +25,8 @@ #define REMOTE_INET_PROTO_H #include "../common/classes/fb_string.h" +#include "../common/classes/RefCounted.h" +#include "../common/config/config.h" namespace Firebird { @@ -32,8 +34,9 @@ } rem_port* INET_analyze(ClntAuthBlock*, const Firebird::PathName&, const TEXT*, - bool, Firebird::ClumpletReader&); -rem_port* INET_connect(const TEXT*, struct packet*, USHORT, Firebird::ClumpletReader*); + bool, Firebird::ClumpletReader&, Firebird::RefPtr<Config>*); +rem_port* INET_connect(const TEXT*, struct packet*, USHORT, Firebird::ClumpletReader*, + Firebird::RefPtr<Config>*); rem_port* INET_reconnect(SOCKET); rem_port* INET_server(SOCKET); void setStopMainThread(FPTR_INT func); Modified: firebird/trunk/src/remote/os/win32/wnet.cpp =================================================================== --- firebird/trunk/src/remote/os/win32/wnet.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/os/win32/wnet.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -73,7 +73,7 @@ static void exit_handler(void*); #endif static void force_close(rem_port*); -static rem_str* make_pipe_name(const TEXT*, const TEXT*, const TEXT*); +static rem_str* make_pipe_name(const RefPtr<Config>&, const TEXT*, const TEXT*, const TEXT*); static rem_port* receive(rem_port*, PACKET*); static int send_full(rem_port*, PACKET*); static int send_partial(rem_port*, PACKET*); @@ -104,7 +104,8 @@ rem_port* WNET_analyze(ClntAuthBlock* cBlock, const PathName& file_name, const TEXT* node_name, - bool uv_flag) + bool uv_flag, + RefPtr<Config>* config) { /************************************** * @@ -181,7 +182,7 @@ rem_port* port = NULL; try { - port = WNET_connect(node_name, packet, 0); + port = WNET_connect(node_name, packet, 0, config); } catch (const Exception&) { @@ -260,7 +261,7 @@ } -rem_port* WNET_connect(const TEXT* name, PACKET* packet, USHORT flag) +rem_port* WNET_connect(const TEXT* name, PACKET* packet, USHORT flag, Firebird::RefPtr<Config>* config) { /************************************** * @@ -275,9 +276,13 @@ * **************************************/ rem_port* const port = alloc_port(0); + if (config) + { + port->port_config = *config; + } delete port->port_connection; - port->port_connection = make_pipe_name(name, SERVER_PIPE_SUFFIX, 0); + port->port_connection = make_pipe_name(port->getPortConfig(), name, SERVER_PIPE_SUFFIX, 0); // If we're a host, just make the connection @@ -412,7 +417,7 @@ rem_port* const port = alloc_port(0); delete port->port_connection; - port->port_connection = make_pipe_name(NULL, SERVER_PIPE_SUFFIX, 0); + port->port_connection = make_pipe_name(port->getPortConfig(), NULL, SERVER_PIPE_SUFFIX, 0); port->port_pipe = handle; port->port_server_flags |= SRVR_server; @@ -582,7 +587,7 @@ port->port_async = new_port; new_port->port_flags = port->port_flags & PORT_no_oob; new_port->port_flags |= PORT_async; - new_port->port_connection = make_pipe_name(port->port_connection->str_data, EVENT_PIPE_SUFFIX, p); + new_port->port_connection = make_pipe_name(port->getPortConfig(), port->port_connection->str_data, EVENT_PIPE_SUFFIX, p); while (true) { @@ -631,7 +636,7 @@ TEXT str_pid[32]; wnet_make_file_name(str_pid, server_pid); new_port->port_connection = - make_pipe_name(vport->port_connection->str_data, EVENT_PIPE_SUFFIX, str_pid); + make_pipe_name(vport->getPortConfig(), vport->port_connection->str_data, EVENT_PIPE_SUFFIX, str_pid); new_port->port_pipe = CreateNamedPipe(new_port->port_connection->str_data, @@ -791,7 +796,7 @@ #endif -static rem_str* make_pipe_name(const TEXT* connect_name, const TEXT* suffix_name, const TEXT* str_pid) +static rem_str* make_pipe_name(RefPtr<Config>& config, const TEXT* connect_name, const TEXT* suffix_name, const TEXT* str_pid) { /************************************** * @@ -820,7 +825,7 @@ switch (*p) { case 0: - protocol = Config::getRemoteServiceName(); + protocol = config->getRemoteServiceName(); break; case '@': protocol = p + 1; @@ -836,7 +841,7 @@ buffer += '\\'; buffer += PIPE_PREFIX; buffer += '\\'; - const char *pipe_name = Config::getRemotePipeName(); + const char *pipe_name = config->getRemotePipeName(); buffer += pipe_name; buffer += '\\'; buffer += suffix_name; Modified: firebird/trunk/src/remote/os/win32/wnet_proto.h =================================================================== --- firebird/trunk/src/remote/os/win32/wnet_proto.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/os/win32/wnet_proto.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -31,8 +31,8 @@ #endif -rem_port* WNET_analyze(ClntAuthBlock*, const Firebird::PathName&, const TEXT*, bool); -rem_port* WNET_connect(const TEXT*, struct packet*, USHORT); +rem_port* WNET_analyze(ClntAuthBlock*, const Firebird::PathName&, const TEXT*, bool, Firebird::RefPtr<Config>*); +rem_port* WNET_connect(const TEXT*, struct packet*, USHORT, Firebird::RefPtr<Config>*); rem_port* WNET_reconnect(HANDLE); Modified: firebird/trunk/src/remote/os/win32/xnet.cpp =================================================================== --- firebird/trunk/src/remote/os/win32/xnet.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/os/win32/xnet.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -61,7 +61,7 @@ static void cleanup_comm(XCC); static void cleanup_mapping(XPM); static void cleanup_port(rem_port*); -static rem_port* connect_client(PACKET*); +static rem_port* connect_client(PACKET*, const Firebird::RefPtr<Config>*); static rem_port* connect_server(USHORT); static void disconnect(rem_port*); static void force_close(rem_port*); @@ -189,7 +189,10 @@ #define ERR_STR(str) (str) #endif -rem_port* XNET_analyze(ClntAuthBlock* cBlock, const PathName& file_name, bool uv_flag) +rem_port* XNET_analyze(ClntAuthBlock* cBlock, + const PathName& file_name, + bool uv_flag, + RefPtr<Config>* config) { /************************************** * @@ -264,7 +267,7 @@ rem_port* port = NULL; try { - port = XNET_connect(packet, 0); + port = XNET_connect(packet, 0, config); } catch (const Exception&) { @@ -345,7 +348,8 @@ rem_port* XNET_connect(PACKET* packet, - USHORT flag) + USHORT flag, + Firebird::RefPtr<Config>* config) { /************************************** * @@ -366,7 +370,7 @@ if (packet) { - return connect_client(packet); + return connect_client(packet, config); } return connect_server(flag); @@ -392,7 +396,7 @@ // Initialize server-side IPC endpoint to a value we know we have permissions to listen at if (strcmp(xnet_endpoint, "") == 0) { - fb_utils::copy_terminate(xnet_endpoint, Config::getIpcName(), sizeof(xnet_endpoint)); + fb_utils::copy_terminate(xnet_endpoint, Config::getDefaultConfig()->getIpcName(), sizeof(xnet_endpoint)); fb_utils::prefix_kernel_object_name(xnet_endpoint, sizeof(xnet_endpoint)); } @@ -1020,7 +1024,7 @@ } -static rem_port* connect_client(PACKET* packet) +static rem_port* connect_client(PACKET* packet, Firebird::RefPtr<Config>* config) { /************************************** * @@ -1033,6 +1037,8 @@ * **************************************/ + Firebird::RefPtr<Config>& conf(config ? *config : Config::getDefaultConfig()); + if (!xnet_initialized) { MutexLockGuard guard(xnet_mutex, FB_FUNCTION); @@ -1055,7 +1061,7 @@ // First, try to connect using default kernel namespace. // This should work on Win9X, NT4 and on later OS when server is running // under restricted account in the same session as the client - fb_utils::copy_terminate(xnet_endpoint, Config::getIpcName(), sizeof(xnet_endpoint)); + fb_utils::copy_terminate(xnet_endpoint, conf->getIpcName(), sizeof(xnet_endpoint)); try { @@ -1066,7 +1072,7 @@ // The client may not have permissions to create global objects, // but still be able to connect to a local server that has such permissions. // This is why we try to connect using Global\ namespace unconditionally - fb_utils::snprintf(xnet_endpoint, sizeof(xnet_endpoint), "Global\\%s", Config::getIpcName()); + fb_utils::snprintf(xnet_endpoint, sizeof(xnet_endpoint), "Global\\%s", conf->getIpcName()); if (!connect_init()) { return NULL; @@ -1078,7 +1084,7 @@ Arg::StatusVector temp; temp << Arg::Gds(isc_net_read_err); - static const int timeout = Config::getConnectionTimeout() * 1000; + static const int timeout = conf->getConnectionTimeout() * 1000; // waiting for XNET connect lock to release @@ -1281,6 +1287,10 @@ port->port_xcc = xcc; xnet_ports->registerPort(port); send_full(port, packet); + if (config) + { + port->port_config = *config; + } return port; } @@ -2126,7 +2136,7 @@ // Initialize server-side IPC endpoint to a value we know we have permissions to listen at if (strcmp(xnet_endpoint, "") == 0) { - fb_utils::copy_terminate(xnet_endpoint, Config::getIpcName(), sizeof(name_buffer)); + fb_utils::copy_terminate(xnet_endpoint, Config::getDefaultConfig()->getIpcName(), sizeof(name_buffer)); fb_utils::prefix_kernel_object_name(xnet_endpoint, sizeof(xnet_endpoint)); } Modified: firebird/trunk/src/remote/os/win32/xnet_proto.h =================================================================== --- firebird/trunk/src/remote/os/win32/xnet_proto.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/os/win32/xnet_proto.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -32,8 +32,8 @@ #define rem_port void #endif -rem_port* XNET_analyze(ClntAuthBlock*, const Firebird::PathName&, bool); -rem_port* XNET_connect(struct packet*, USHORT); +rem_port* XNET_analyze(ClntAuthBlock*, const Firebird::PathName&, bool, Firebird::RefPtr<Config>*); +rem_port* XNET_connect(struct packet*, USHORT, Firebird::RefPtr<Config>*); rem_port* XNET_reconnect(ULONG); #endif // REMOTE_XNET_PROTO_H Modified: firebird/trunk/src/remote/remot_proto.h =================================================================== --- firebird/trunk/src/remote/remot_proto.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/remot_proto.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -58,7 +58,7 @@ void REMOTE_save_status_strings (ISC_STATUS *); bool_t REMOTE_getbytes (XDR*, SCHAR*, u_int); bool REMOTE_legacy_auth(const char* nm, int protocol); -Firebird::RefPtr<Config> REMOTE_get_config(const Firebird::PathName* dbName); +Firebird::RefPtr<Config> REMOTE_get_config(const Firebird::PathName* dbName, const Firebird::string* dpb_config); void REMOTE_parseList(Remote::ParsedList&, Firebird::PathName); void REMOTE_makeList(Firebird::PathName& list, const Remote::ParsedList& parsed); void REMOTE_check_response(Firebird::IStatus* warning, Rdb* rdb, PACKET* packet, bool checkKeys = false); Modified: firebird/trunk/src/remote/remote.cpp =================================================================== --- firebird/trunk/src/remote/remote.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/remote.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -65,7 +65,8 @@ isc_dpb_client_version, isc_dpb_remote_protocol, isc_dpb_host_name, - isc_dpb_os_user + isc_dpb_os_user, + isc_dpb_config }; const ParametersSet spbParam = @@ -86,7 +87,8 @@ isc_spb_client_version, isc_spb_remote_protocol, isc_spb_host_name, - isc_spb_os_user + isc_spb_os_user, + isc_spb_config }; const ParametersSet spbStartParam = @@ -107,6 +109,7 @@ 0, 0, 0, + 0, 0 }; @@ -128,6 +131,7 @@ 0, 0, 0, + 0, 0 }; @@ -438,10 +442,10 @@ fb_assert(isc_dpb_connect_timeout == isc_spb_connect_timeout); port->port_connect_timeout = - pb && pb->find(isc_dpb_connect_timeout) ? pb->getInt() : Config::getConnectionTimeout(); + pb && pb->find(isc_dpb_connect_timeout) ? pb->getInt() : port->getPortConfig()->getConnectionTimeout(); port->port_flags |= PORT_dummy_pckt_set; - port->port_dummy_packet_interval = Config::getDummyPacketInterval(); + port->port_dummy_packet_interval = port->getPortConfig()->getDummyPacketInterval(); if (port->port_dummy_packet_interval < 0) port->port_dummy_packet_interval = DUMMY_INTERVAL; @@ -682,10 +686,16 @@ this->port_next = parent->port_clients; this->port_server = parent->port_server; this->port_server_flags = parent->port_server_flags; + this->port_config = parent->port_config; parent->port_clients = parent->port_next = this; } +const Firebird::RefPtr<Config>& rem_port::getPortConfig() const +{ + return port_config.hasData() ? port_config : Config::getDefaultConfig(); +} + void rem_port::unlinkParent() { if (this->port_parent == NULL) @@ -1063,32 +1073,42 @@ } } -void ClntAuthBlock::reset(const Firebird::PathName* fileName) +void ClntAuthBlock::resetClnt(const Firebird::PathName* fileName) { dataForPlugin.clear(); dataFromPlugin.clear(); authComplete = false; firstTime = true; - pluginList = REMOTE_get_config(fileName)->getPlugins(Firebird::PluginType::AuthClient); + config = REMOTE_get_config(fileName, &dpbConfig); + pluginList = config->getPlugins(Firebird::PluginType::AuthClient); plugins.set(pluginList.c_str()); } +Firebird::RefPtr<Config>* ClntAuthBlock::getConfig() +{ + return config.hasData() ? &config : NULL; +} + void ClntAuthBlock::storeDataForPlugin(unsigned int length, const unsigned char* data) { dataForPlugin.assign(data, length); HANDSHAKE_DEBUG(fprintf(stderr, "Cln: accepted data for plugin length=%d\n", length)); } -Firebird::RefPtr<Config> REMOTE_get_config(const Firebird::PathName* dbName) +Firebird::RefPtr<Config> REMOTE_get_config(const Firebird::PathName* dbName, + const Firebird::string* dpb_config) { + Firebird::RefPtr<Config> rc = Config::getDefaultConfig(); + if (dbName) { - Firebird::RefPtr<Config> rc; Firebird::PathName dummy; expandDatabaseName(*dbName, dummy, &rc); - return rc; } - return Config::getDefaultConfig(); + + Config::merge(rc, dpb_config); + + return rc; } void REMOTE_parseList(Remote::ParsedList& parsed, Firebird::PathName list) @@ -1276,7 +1296,7 @@ return false; } - if (Config::getWireCrypt(WC_CLIENT) == WIRE_CRYPT_DISABLED) + if (getPortConfig()->getWireCrypt(WC_CLIENT) == WIRE_CRYPT_DISABLED) { port_crypt_complete = true; return true; @@ -1285,7 +1305,7 @@ // we got correct key's type pair // check what about crypt plugin for it Remote::ParsedList clientPlugins; - REMOTE_parseList(clientPlugins, Config::getDefaultConfig()->getPlugins(Firebird::PluginType::WireCrypt)); + REMOTE_parseList(clientPlugins, getPortConfig()->getPlugins(Firebird::PluginType::WireCrypt)); for (unsigned n = 0; n < clientPlugins.getCount(); ++n) { Firebird::PathName p(clientPlugins[n]); Modified: firebird/trunk/src/remote/remote.h =================================================================== --- firebird/trunk/src/remote/remote.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/remote.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -113,7 +113,7 @@ plugin_name, plugin_list, specific_data, address_path, process_id, process_name, encrypt_key, client_version, remote_protocol, - host_name, os_user; + host_name, os_user, config_text; }; extern const ParametersSet dpbParam, spbParam, spbStartParam, spbInfoParam; @@ -639,6 +639,8 @@ // These two are legacy encrypted password, trusted auth data and so on - what plugin needs Firebird::UCharBuffer dataForPlugin, dataFromPlugin; Firebird::HalfStaticArray<InternalCryptKey*, 1> cryptKeys; // Wire crypt keys that came from plugin(s) last time + Firebird::string dpbConfig; // Used to recreate config with new filename + Firebird::RefPtr<Config> config; // Used to get plugins list and pass to port unsigned nextKey; // First key to be analyzed bool hasCryptKey; // DPB contains disk crypt key, may be passed only over encrypted wire @@ -648,7 +650,7 @@ bool authComplete; // Set as response from client that authentication accepted bool firstTime; // Invoked first time after reset - explicit ClntAuthBlock(const Firebird::PathName* fileName); + ClntAuthBlock(const Firebird::PathName* fileName, Firebird::ClumpletReader* dpb, const ParametersSet* tags); ~ClntAuthBlock() { @@ -660,15 +662,16 @@ void extractDataFromPluginTo(Firebird::ClumpletWriter& dpb, const ParametersSet* tags, int protocol); void extractDataFromPluginTo(CSTRING* to); void extractDataFromPluginTo(P_AUTH_CONT* to); - void load(Firebird::ClumpletReader& dpb, const ParametersSet*); + void loadClnt(Firebird::ClumpletReader& dpb, const ParametersSet*); void extractDataFromPluginTo(Firebird::ClumpletWriter& user_id); - void reset(const Firebird::PathName* fileName); + void resetClnt(const Firebird::PathName* fileName); bool checkPluginName(Firebird::PathName& nameToCheck); void saveServiceDataTo(rem_port*); void loadServiceDataFrom(rem_port*); Firebird::PathName getPluginName(); void tryNewKeys(rem_port*); void releaseKeys(unsigned from); + Firebird::RefPtr<Config>* getConfig(); // Auth::IClientBlock implementation int FB_CARG release(); @@ -873,6 +876,7 @@ OBJCT port_last_object_id; // cached last id Firebird::ObjectsArray< Firebird::Array<char> > port_queue; size_t port_qoffset; // current packet in the queue + Firebird::RefPtr<Config> port_config; // connection-specific configuration info // Authentication and crypt stuff ServerAuthBase* port_srv_auth; @@ -934,8 +938,8 @@ public: void linkParent(rem_port* const parent); - void unlinkParent(); + const Firebird::RefPtr<Config>& getPortConfig() const; template <typename T> void getHandle(T*& blk, OBJCT id) Modified: firebird/trunk/src/remote/server/os/posix/inet_server.cpp =================================================================== --- firebird/trunk/src/remote/server/os/posix/inet_server.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/server/os/posix/inet_server.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -292,6 +292,11 @@ INET_SERVER_flag |= SRVR_multi_client; super = true; } + { // scope + Firebird::MasterInterfacePtr master; + master->serverMode(super ? 1 : 0); + } + if (debug) { INET_SERVER_flag |= SRVR_debug; @@ -356,7 +361,7 @@ { try { - port = INET_connect(protocol, 0, INET_SERVER_flag, 0); + port = INET_connect(protocol, 0, INET_SERVER_flag, 0, NULL); } catch (const Firebird::Exception& ex) { Modified: firebird/trunk/src/remote/server/server.cpp =================================================================== --- firebird/trunk/src/remote/server/server.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/remote/server/server.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -1890,6 +1890,9 @@ case isc_dpb_user_name: case isc_dpb_password: case isc_dpb_password_enc: + + // remove client's config information + case isc_dpb_config: pb->deleteClumplet(); break; @@ -1973,7 +1976,8 @@ send->p_resp.p_resp_data.cstr_address = buffer; // To be retrieved via an overloaded class member once our ports become real classes - const int aux_port_id = (port->port_type == rem_port::INET) ? Config::getRemoteAuxPort() : 0; + const int aux_port_id = (port->port_type == rem_port::INET) ? + Config::getDefaultConfig()->getRemoteAuxPort() : 0; GlobalPortLock auxPortLock(aux_port_id); rem_port* const aux_port = port->request(send); @@ -5091,10 +5095,6 @@ // Now insert additional clumplets into spb addClumplets(spb, spbParam, this); - // See if user has specified parameters relevent to the connection, - // they will be stuffed in the SPB if so. - REMOTE_get_timeout_params(this, spb); - // Get ready to cache old-style auth parameters ClumpletWriter* cache = NULL; if (!authenticated) @@ -5120,6 +5120,9 @@ // remove trusted auth & trusted role if present (security measure) case isc_spb_trusted_role: case isc_spb_trusted_auth: + + // remove user config info (security measure) + case isc_spb_config: spb->deleteClumplet(); break; @@ -5129,6 +5132,10 @@ } } + // See if user has specified parameters relevent to the connection, + // they will be stuffed in the SPB if so. + REMOTE_get_timeout_params(this, spb); + if (!authenticated) { // add fake auth block to have additional guarantee that this service never reachs database @@ -6369,7 +6376,7 @@ Remote::ParsedList fromClient; REMOTE_parseList(fromClient, pluginList); - RefPtr<Config> myConfig = REMOTE_get_config(dbPath.hasData() ? &dbPath : NULL); + RefPtr<Config> myConfig = REMOTE_get_config(dbPath.hasData() ? &dbPath : NULL, NULL); Remote::ParsedList onServer; REMOTE_parseList(onServer, myConfig->getPlugins(PluginType::AuthServer)); @@ -6426,7 +6433,7 @@ REMOTE_makeList(pluginList, final); plugins = new AuthServerPlugins(PluginType::AuthServer, FB_AUTH_SERVER_VERSION, upInfo, - myConfig, pluginList.c_str()); + myConfig, pluginList.c_str()); } void SrvAuthBlock::reset() Modified: firebird/trunk/src/utilities/gsec/gsec.cpp =================================================================== --- firebird/trunk/src/utilities/gsec/gsec.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/utilities/gsec/gsec.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -333,7 +333,8 @@ #else false, #endif - serverName.c_str()); + serverName.c_str(), + !databaseNameEntered); if (! sHandle) { GSEC_print(GsecMsg101); // use gsec -? to get help Modified: firebird/trunk/src/yvalve/MasterImplementation.cpp =================================================================== --- firebird/trunk/src/yvalve/MasterImplementation.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/yvalve/MasterImplementation.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -264,6 +264,14 @@ #endif } +int FB_CARG MasterImplementation::serverMode(int mode) +{ + static int currentMode = -1; + if (mode >= 0) + currentMode = mode; + return currentMode; +} + } // namespace Why // Modified: firebird/trunk/src/yvalve/MasterImplementation.h =================================================================== --- firebird/trunk/src/yvalve/MasterImplementation.h 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/yvalve/MasterImplementation.h 2013-04-04 13:17:57 UTC (rev 57896) @@ -68,6 +68,7 @@ int FB_CARG same(IVersioned* first, IVersioned* second); Firebird::IMetadataBuilder* FB_CARG getMetadataBuilder(Firebird::IStatus* status, unsigned fieldCount); Firebird::IDebug* FB_CARG getDebug(); + int FB_CARG serverMode(int mode); }; void shutdownTimers(); Modified: firebird/trunk/src/yvalve/why.cpp =================================================================== --- firebird/trunk/src/yvalve/why.cpp 2013-04-04 00:46:59 UTC (rev 57895) +++ firebird/trunk/src/yvalve/why.cpp 2013-04-04 13:17:57 UTC (rev 57896) @@ -4884,8 +4884,18 @@ const char* serviceName, unsigned int spbLength, const unsigned char* spb, Firebird::ICryptKeyCallback* cryptCallback) { + RefPtr<Config> config(Config::getDefaultConfig()); + + ClumpletReader readSpb(ClumpletReader::spbList, spb, spbLength); + if (readSpb.find(isc_spb_config)) + { + string spb_config; + readSpb.getString(spb_config); + Config::merge(config, &spb_config); + } + for (GetPlugins<IProvider> providerIterator(PluginType::Provider, - FB_PROVIDER_VERSION, upInfo); + FB_PROVIDER_VERSION, upInfo, config); providerIterator.hasData(); providerIterator.next()) { @@ -5211,6 +5221,13 @@ expandedFilename = orgFilename; } + if (newDpb.find(isc_dpb_config)) + { + string dpb_config; + newDpb.getString(dpb_config); + Config::merge(config, &dpb_config); + } + // Convert to UTF8 ISC_systemToUtf8(orgFilename); ISC_systemToUtf8(expandedFilename); @@ -5249,7 +5266,7 @@ { // Now we can expand, the file exists ISC_utf8ToSystem(orgFilename); - if (expandDatabaseName(orgFilename, expandedFilename, &config)) + if (expandDatabaseName(orgFilename, expandedFilename, NULL)) { expandedFilename = orgFilename; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |