Skip to content

Commit 27f7d41

Browse files
committed
Fixed #8644: Connection error via Loopback provider if it's the first in the Providers parameter
1 parent db108e3 commit 27f7d41

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/jrd/extds/IscDS.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,22 @@ void IscConnection::attach(thread_db* tdbb)
110110

111111
// Avoid change of m_dpb by validatePassword() below
112112
ClumpletWriter newDpb(ClumpletReader::dpbList, MAX_DPB_SIZE, m_dpb.begin(), m_dpb.getCount());
113-
validatePassword(tdbb, m_dbName, newDpb);
113+
if (validatePassword(tdbb, m_dbName, newDpb))
114+
{
115+
// After successful password validation only local for current server providers
116+
// should be used. Currently we do not distinguish provider's properties
117+
// therefore use working but definitely not ideal way to avoid remote & loopback
118+
// providers to be used - add empty isc_dpb_address_path clumplet to DPB.
119+
// See also get_new_dpb() in interface.cpp.
120+
121+
ClumpletWriter address_record(ClumpletReader::UnTagged, MAX_UCHAR - 2);
122+
ClumpletWriter address_stack_buffer(ClumpletReader::UnTagged, MAX_UCHAR - 2);
123+
address_stack_buffer.insertBytes(isc_dpb_address,
124+
address_record.getBuffer(), address_record.getBufferLength());
125+
126+
newDpb.insertBytes(isc_dpb_address_path, address_stack_buffer.getBuffer(),
127+
address_stack_buffer.getBufferLength());
128+
}
114129
newDpb.insertInt(isc_dpb_ext_call_depth, attachment->att_ext_call_depth + 1);
115130

116131
if (newDpb.getBufferLength() > MAX_USHORT)

src/jrd/extds/ValidatePassword.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,18 @@ void SBlock::putData(CheckStatusWrapper* status, unsigned int length, const void
172172

173173
namespace EDS {
174174

175-
void validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb)
175+
bool validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb)
176176
{
177177
// Preliminary checks - should we really validate the password ourselves
178178
if (!dpb.find(isc_dpb_user_name)) // check for user name presence
179-
return;
179+
return false;
180180
if (ISC_check_if_remote(file, false)) // check for remote connection
181-
return;
181+
return false;
182182
UserId* usr = tdbb->getAttachment()->att_user;
183183
if (!usr)
184-
return;
184+
return false;
185185
if (!usr->usr_auth_block.hasData()) // check for embedded attachment
186-
return;
186+
return false;
187187

188188
Arg::Gds loginError(isc_login_error);
189189

@@ -264,10 +264,13 @@ void validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb
264264
switch (server.plugin()->authenticate(&s, &sBlock, &writer))
265265
{
266266
case IAuth::AUTH_SUCCESS:
267+
// remove isc_dpb_user_name cause it has precedence over isc_dpb_auth_block
267268
dpb.deleteWithTag(isc_dpb_user_name);
269+
// isc_dpb_password makes no sense w/o isc_dpb_user_name
268270
dpb.deleteWithTag(isc_dpb_password);
271+
// save built by this routine isc_dpb_auth_block
269272
writer.store(&dpb, isc_dpb_auth_block);
270-
return;
273+
return true;
271274

272275
case IAuth::AUTH_CONTINUE:
273276
limit = MAXLIMIT;

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)