From: "Aleksey N. Vinogradov" <a.n.vinogradov@gmail.com>
Date: Fri, 3 Dec 2021 10:07:23 +0100
Subject: Support MySQL 8 clients

Origin: other, https://github.com/manticoresoftware/manticoresearch/commit/ed98fdd7230c1d7298e1000fd10812338c6ba698
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/sphinxsearch/+bug/1855468
Reviewed-by: Lucas Kanashiro <lucas.kanashiro@canonical.com>
Last-Update: 2019-12-06

The handshsake implementation of version 2.2.11 does not support MySQL 8
clients, not allowing them to connect to searchd using the MySQL protocol.
It was fixed in version 3.3.1 according to the release notes:
http://sphinxsearch.com/docs/sphinx3.html#version-3.1.1-17-oct-2018 .

This patch was cherry-picked from manticoresearch project which is a
sphinxsearch fork with the same handshake implementation.
Last-Update: 2019-12-06
---
 src/searchd.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/searchd.cpp b/src/searchd.cpp
index 6462b16..0271142 100644
--- a/src/searchd.cpp
+++ b/src/searchd.cpp
@@ -23028,13 +23028,14 @@ void ConfigureSearchd ( const CSphConfig & hConf, bool bOptPIDFile )
 
 	char sHandshake2[] =
 		"\x01\x00\x00\x00" // thread id
-		"\x01\x02\x03\x04\x05\x06\x07\x08" // scramble buffer (for auth)
+		"\x01\x02\x03\x04\x05\x06\x07\x08" // salt1 (for auth)
 		"\x00" // filler
 		"\x08\x82" // server capabilities; CLIENT_PROTOCOL_41 | CLIENT_CONNECT_WITH_DB | CLIENT_SECURE_CONNECTION
 		"\x21" // server language; let it be ut8_general_ci to make different clients happy
 		"\x02\x00" // server status
 		"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // filler
-		"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d"; // scramble buffer2 (for auth, 4.1+)
+		"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c" // salt2 (for auth, 4.1+)
+		"\x00"; // filler
 
 	const char * sVersion = hSearchd.GetStr ( "mysql_version_string", SPHINX_VERSION );
 	int iLen = strlen ( sVersion );
