Skip to content

Commit 2260537

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

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

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

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

src/remote/protocol.h

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

141142
// Generic object id
142143

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)