Skip to content

Commit 37079f1

Browse files
committed
Additional fix for #8256 : the case when server doesn't return error immediately after connect.
1 parent aa167e2 commit 37079f1

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
@@ -7417,6 +7417,7 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
74177417
while (true)
74187418
{
74197419
authenticateStep0(cBlock);
7420+
const NoCaseString savePluginName(cBlock.plugins.name());
74207421

74217422
try
74227423
{
@@ -7504,6 +7505,38 @@ static rem_port* analyze(ClntAuthBlock& cBlock, PathName& attach_name, unsigned
75047505
}
75057506
}
75067507

7508+
#ifdef TRUSTED_AUTH
7509+
if (port && !legacySSP)
7510+
{
7511+
const PACKET& const packet = port->port_context->rdb_packet;
7512+
if (port->port_protocol < PROTOCOL_VERSION13 && packet.p_operation == op_accept)
7513+
{
7514+
// old server supports legacy SSP only
7515+
legacySSP = true;
7516+
}
7517+
else if (port->port_protocol >= PROTOCOL_VERSION13 && packet.p_operation == op_accept_data)
7518+
{
7519+
// more recent server reports if it supports non-legacy SSP
7520+
legacySSP = !(packet.p_acpd.p_acpt_type & pflag_win_sspi_nego);
7521+
}
7522+
else
7523+
break;
7524+
7525+
Auth::setLegacySSP(legacySSP);
7526+
7527+
if (legacySSP && savePluginName == "WIN_SSPI")
7528+
{
7529+
// reinitialize Win_SSPI plugin and send new data
7530+
attach_name = save_attach_name;
7531+
7532+
cBlock.plugins.set(savePluginName.c_str());
7533+
7534+
disconnect(port, false);
7535+
continue;
7536+
}
7537+
}
7538+
#endif
7539+
75077540
break;
75087541
}
75097542
catch (const Exception&)

src/remote/protocol.h

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

146147
// Generic object id
147148

src/remote/server/server.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,9 @@ static bool accept_connection(rem_port* port, P_CNCT* connect, PACKET* send)
19851985
send->p_acpd.p_acpt_version = port->port_protocol = version;
19861986
send->p_acpd.p_acpt_architecture = architecture;
19871987
send->p_acpd.p_acpt_type = type | (compress ? pflag_compress : 0);
1988+
#ifdef TRUSTED_AUTH
1989+
send->p_acpd.p_acpt_type |= pflag_win_sspi_nego;
1990+
#endif
19881991
send->p_acpd.p_acpt_authenticated = 0;
19891992

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

0 commit comments

Comments
 (0)