Merge pull request #1165 from kedixa/dev

mysql empty password auth
This commit is contained in:
xiehan
2023-02-10 22:10:18 +08:00
committed by GitHub
2 changed files with 11 additions and 3 deletions
+6 -2
View File
@@ -369,7 +369,7 @@ int ComplexMySQLTask::check_handshake(MySQLHandshakeResponse *resp)
auto *my_conn = new MyConnection(ssl);
my_conn->str = resp->get_auth_plugin_name();
if (my_conn->str == "sha256_password")
if (!password_.empty() && my_conn->str == "sha256_password")
my_conn->str = "caching_sha2_password";
resp->get_seed(my_conn->seed);
@@ -397,7 +397,11 @@ int ComplexMySQLTask::auth_switch(MySQLAuthResponse *resp, MyConnection *conn)
return 0;
}
if (name == "sha256_password")
if (password_.empty())
{
conn->state = ST_CLEAR_PASSWORD_REQUEST;
}
else if (name == "sha256_password")
{
if (is_ssl_)
conn->state = ST_CLEAR_PASSWORD_REQUEST;
+5 -1
View File
@@ -491,7 +491,11 @@ int MySQLAuthResponse::decode_packet(const unsigned char *buf, size_t buflen)
int MySQLAuthSwitchRequest::encode(struct iovec vectors[], int max)
{
if (auth_plugin_name_ == MYSQL_NATIVE_PASSWORD)
if (password_.empty())
{
buf_ = "\0";
}
else if (auth_plugin_name_ == MYSQL_NATIVE_PASSWORD)
{
buf_ = __native_password_encrypt(password_, seed_);
}