Skip to content

Commit 5343055

Browse files
committed
Fixed #8644: Connection error via Loopback provider if it's the first in the Providers parameter
(cherry picked from commit 27f7d41)
1 parent c90ea97 commit 5343055

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/jrd/extds/IscDS.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,22 @@ void IscConnection::attach(thread_db* tdbb, const PathName& dbName, const string
119119

120120
// Avoid change of m_dpb by validatePassword() below
121121
ClumpletWriter newDpb(m_dpb);
122-
validatePassword(tdbb, m_dbName, newDpb);
122+
if (validatePassword(tdbb, m_dbName, newDpb))
123+
{
124+
// After successful password validation only local for current server providers
125+
// should be used. Currently we do not distinguish provider's properties
126+
// therefore use working but definitely not ideal way to avoid remote & loopback
127+
// providers to be used - add empty isc_dpb_address_path clumplet to DPB.
128+
// See also get_new_dpb() in interface.cpp.
129+
130+
ClumpletWriter address_record(ClumpletReader::UnTagged, MAX_UCHAR - 2);
131+
ClumpletWriter address_stack_buffer(ClumpletReader::UnTagged, MAX_UCHAR - 2);
132+
address_stack_buffer.insertBytes(isc_dpb_address,
133+
address_record.getBuffer(), address_record.getBufferLength());
134+
135+
newDpb.insertBytes(isc_dpb_address_path, address_stack_buffer.getBuffer(),
136+
address_stack_buffer.getBufferLength());
137+
}
123138

124139
if (newDpb.getBufferLength() > MAX_USHORT)
125140
{

src/jrd/extds/ValidatePassword.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,18 @@ void SBlock::putData(CheckStatusWrapper* status, unsigned int length, const void
169169

170170
namespace EDS {
171171

172-
void validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb)
172+
bool validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb)
173173
{
174174
// Peliminary checks - should we really validate password ourself
175175
if (!dpb.find(isc_dpb_user_name)) // check for user name presence
176-
return;
176+
return false;
177177
if (ISC_check_if_remote(file, false)) // check for remote connection
178-
return;
178+
return false;
179179
UserId* usr = tdbb->getAttachment()->att_user;
180+
if (!usr)
181+
return false;
180182
if (!usr->usr_auth_block.hasData()) // check for embedded attachment
181-
return;
183+
return false;
182184

183185
Arg::Gds loginError(isc_login_error);
184186

@@ -260,10 +262,13 @@ void validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb
260262
switch (server.plugin()->authenticate(&s, &sBlock, &writer))
261263
{
262264
case IAuth::AUTH_SUCCESS:
265+
// remove isc_dpb_user_name cause it has precedence over isc_dpb_auth_block
263266
dpb.deleteWithTag(isc_dpb_user_name);
267+
// isc_dpb_password makes no sense w/o isc_dpb_user_name
264268
dpb.deleteWithTag(isc_dpb_password);
269+
// save built by this routine isc_dpb_auth_block
265270
writer.store(&dpb, isc_dpb_auth_block);
266-
return;
271+
return true;
267272

268273
case IAuth::AUTH_CONTINUE:
269274
limit = MAXLIMIT;
@@ -289,6 +294,7 @@ void validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb
289294
}
290295

291296
Arg::Gds(isc_login).raise();
297+
return false; // warning silencer
292298
}
293299

294300
} // namespace EDS

src/jrd/extds/ValidatePassword.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Jrd
3434

3535
namespace EDS {
3636

37-
void validatePassword(Jrd::thread_db* tdbb, const Firebird::PathName& file,
37+
bool validatePassword(Jrd::thread_db* tdbb, const Firebird::PathName& file,
3838
Firebird::ClumpletWriter& dpb);
3939

4040
} // namespace EDS

0 commit comments

Comments
 (0)