MXS-1525 Check exact match first when checking host

Given a rule like

  ...
  users %@127.0.0.1 match any rules ...

the code started with %@127.0.0.%, which meant that the exact
match rule would be missed.
This commit is contained in:
Johan Wikman
2017-11-16 13:52:28 +02:00
parent 11a240cb15
commit decd5578bc

View File

@ -1272,6 +1272,10 @@ static SUser find_user_data(const UserMap& users, std::string name, std::string
if (it == users.end())
{
snprintf(nameaddr, sizeof(nameaddr), "%%@%s", remote.c_str());
it = users.find(nameaddr);
if (it == users.end())
{
ip_start = strchr(nameaddr, '@') + 1;
while (it == users.end() && next_ip_class(ip_start))
@ -1280,6 +1284,7 @@ static SUser find_user_data(const UserMap& users, std::string name, std::string
}
}
}
}
return it != users.end() ? it->second : SUser();
}