|
From: <ale...@us...> - 2012-11-01 14:38:21
|
Revision: 57285
http://firebird.svn.sourceforge.net/firebird/?rev=57285&view=rev
Author: alexpeshkoff
Date: 2012-11-01 14:38:14 +0000 (Thu, 01 Nov 2012)
Log Message:
-----------
Begin wire crypt only after successfull authentication - this helps avoid meaningless message when password is wrong, thanks to Vlad
Modified Paths:
--------------
firebird/trunk/src/remote/client/interface.cpp
firebird/trunk/src/remote/remot_proto.h
firebird/trunk/src/remote/remote.cpp
firebird/trunk/src/remote/server/server.cpp
Modified: firebird/trunk/src/remote/client/interface.cpp
===================================================================
--- firebird/trunk/src/remote/client/interface.cpp 2012-11-01 12:03:18 UTC (rev 57284)
+++ firebird/trunk/src/remote/client/interface.cpp 2012-11-01 14:38:14 UTC (rev 57285)
@@ -4638,13 +4638,6 @@
// We have a local connection string. If it's a file on a network share,
// try to connect to the corresponding host remotely.
-
- if (port)
- {
- cBlock.tryNewKeys(port);
- return port;
- }
-
#ifdef WIN_NT
PathName expanded_name = file_name;
ISC_expand_share(expanded_name);
@@ -4697,10 +4690,6 @@
}
}
- if (port)
- {
- cBlock.tryNewKeys(port);
- }
return port;
}
@@ -5504,7 +5493,6 @@
// OK to use plugin
cBlock.resetDataFromPlugin();
int authRc = cBlock.plugins.plugin()->authenticate(&s, &cBlock);
- cBlock.tryNewKeys(port);
switch (authRc)
{
@@ -5589,13 +5577,16 @@
CSTRING* tmpKeys = REMOTE_dup_string(&packet->p_crypt.p_key);
// it was start crypt packet, receive next one
receive_response(status, rdb, packet);
- // now try to start crypt
+ // add received keys to the list of known
if (tmpKeys)
{
port->addServerKeys(tmpKeys);
REMOTE_free_string(tmpKeys);
}
}
+
+ // try to start crypt
+ cBlock.tryNewKeys(port);
return;
default:
@@ -5604,6 +5595,9 @@
// successfully attached
HANDSHAKE_DEBUG(fprintf(stderr, "RR: OK!\n"));
rdb->rdb_id = packet->p_resp.p_resp_object;
+
+ // try to start crypt
+ cBlock.tryNewKeys(port);
return;
}
@@ -5638,7 +5632,6 @@
{
break;
}
- cBlock.tryNewKeys(port);
// send answer (may be empty) to server
if (port->port_protocol >= PROTOCOL_VERSION13)
Modified: firebird/trunk/src/remote/remot_proto.h
===================================================================
--- firebird/trunk/src/remote/remot_proto.h 2012-11-01 12:03:18 UTC (rev 57284)
+++ firebird/trunk/src/remote/remot_proto.h 2012-11-01 14:38:14 UTC (rev 57285)
@@ -64,5 +64,6 @@
void REMOTE_check_response(Firebird::IStatus* warning, Rdb* rdb, PACKET* packet, bool checkKeys = false);
#define HANDSHAKE_DEBUG(A)
+#define WIRECRYPT_DEBUG(A)
#endif // REMOTE_REMOT_PROTO_H
Modified: firebird/trunk/src/remote/remote.cpp
===================================================================
--- firebird/trunk/src/remote/remote.cpp 2012-11-01 12:03:18 UTC (rev 57284)
+++ firebird/trunk/src/remote/remote.cpp 2012-11-01 14:38:14 UTC (rev 57285)
@@ -1219,6 +1219,13 @@
Firebird::status_exception::raise(vector);
}
+static void setCStr(CSTRING& to, const char* from)
+{
+ to.cstr_address = reinterpret_cast<UCHAR*>(const_cast<char*>(from));
+ to.cstr_length = strlen(from);
+ to.cstr_allocated = 0;
+}
+
void rem_port::addServerKeys(CSTRING* passedStr)
{
Firebird::ClumpletReader newKeys(Firebird::ClumpletReader::UnTagged,
@@ -1239,14 +1246,6 @@
key.plugins += ' ';
key.plugins.insert(0, " ");
- for (unsigned k = 0; k < port_crypt_keys.getCount(); ++k)
- {
- if (tryKeyType(key, port_crypt_keys[k]))
- {
- return;
- }
- }
-
port_known_server_keys.add(key);
}
}
@@ -1265,13 +1264,6 @@
return false;
}
-static void setCStr(CSTRING& to, const char* from)
-{
- to.cstr_address = reinterpret_cast<UCHAR*>(const_cast<char*>(from));
- to.cstr_length = strlen(from);
- to.cstr_allocated = 0;
-}
-
bool rem_port::tryKeyType(const KnownServerKey& srvKey, InternalCryptKey* cryptKey)
{
if (port_crypt_complete)
Modified: firebird/trunk/src/remote/server/server.cpp
===================================================================
--- firebird/trunk/src/remote/server/server.cpp 2012-11-01 12:03:18 UTC (rev 57284)
+++ firebird/trunk/src/remote/server/server.cpp 2012-11-01 14:38:14 UTC (rev 57285)
@@ -5358,7 +5358,7 @@
port_crypt_complete = true;
send_response(sendL, 0, 0, &st, false);
- // fprintf(stderr, "Installed cipher %s key %s\n", cp.name(), key->type);
+ WIRECRYPT_DEBUG(fprintf(stderr, "Installed cipher %s key %s\n", cp.name(), key->type));
}
catch(const Exception& ex)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|