Skip to content

Commit 2d4883b

Browse files
committed
Additional fix for #8256 : the case when server doesn't return error immediately after connect.
1 parent 85136d2 commit 2d4883b

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/remote/client/interface.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7179,6 +7179,7 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
71797179
while (true)
71807180
{
71817181
authenticateStep0(cBlock);
7182+
const NoCaseString savePluginName(cBlock.plugins.name());
71827183

71837184
try
71847185
{
@@ -7288,6 +7289,38 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
72887289
}
72897290
}
72907291

7292+
#ifdef TRUSTED_AUTH
7293+
if (port && !legacySSP)
7294+
{
7295+
const PACKET& const packet = port->port_context->rdb_packet;
7296+
if (port->port_protocol < PROTOCOL_VERSION13 && packet.p_operation == op_accept)
7297+
{
7298+
// old server supports legacy SSP only
7299+
legacySSP = true;
7300+
}
7301+
else if (port->port_protocol >= PROTOCOL_VERSION13 && packet.p_operation == op_accept_data)
7302+
{
7303+
// more recent server reports if it supports non-legacy SSP
7304+
legacySSP = !(packet.p_acpd.p_acpt_type & pflag_win_sspi_nego);
7305+
}
7306+
else
7307+
break;
7308+
7309+
Auth::setLegacySSP(legacySSP);
7310+
7311+
if (legacySSP && savePluginName == "WIN_SSPI")
7312+
{
7313+
// reinitialize Win_SSPI plugin and send new data
7314+
attach_name = save_attach_name;
7315+
7316+
cBlock.plugins.set(savePluginName.c_str());
7317+
7318+
disconnect(port, false);
7319+
continue;
7320+
}
7321+
}
7322+
#endif
7323+
72917324
break;
72927325
}
72937326
catch (const Exception&)

src/remote/protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ const USHORT ptype_lazy_send = 5; // Deferred packets delivery
130130
const USHORT ptype_MASK = 0xFF; // Mask - up to 255 types of protocol
131131
//
132132
// upper byte is used for protocol flags
133-
const USHORT pflag_compress = 0x100; // Turn on compression if possible
133+
const USHORT pflag_compress = 0x100; // Turn on compression if possible
134+
const USHORT pflag_win_sspi_nego = 0x200; // Win_SSPI supports Negotiate security package
134135

135136
// Generic object id
136137

src/remote/server/server.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,9 @@ static bool accept_connection(rem_port* port, P_CNCT* connect, PACKET* send)
19601960
send->p_acpd.p_acpt_version = port->port_protocol = version;
19611961
send->p_acpd.p_acpt_architecture = architecture;
19621962
send->p_acpd.p_acpt_type = type | (compress ? pflag_compress : 0);
1963+
#ifdef TRUSTED_AUTH
1964+
send->p_acpd.p_acpt_type |= pflag_win_sspi_nego;
1965+
#endif
19631966
send->p_acpd.p_acpt_authenticated = 0;
19641967

19651968
send->p_acpt.p_acpt_version = port->port_protocol = version;

0 commit comments

Comments
 (0)