MXS-2642 Do not re-test a pam-service for a given user

Because of how the user-data was read, the same service name could be
found multiple times if the user-search query matched multiple rows. Now
the service names are read to a set, which ignores duplicates. The same
service may be attempted again if the authentication fails and user-data
is fetched again.
This commit is contained in:
Esa Korhonen
2019-08-27 15:34:44 +03:00
parent 7a1abc26d8
commit 6edbd52324
2 changed files with 14 additions and 15 deletions

View File

@ -15,7 +15,7 @@
#include <stdint.h>
#include <string>
#include <vector>
#include <set>
#include <maxscale/sqlite3.h>
#include "pam_instance.hh"
#include "../pam_auth_common.hh"
@ -26,14 +26,14 @@ class PamClientSession
PamClientSession(const PamClientSession& orig);
PamClientSession& operator=(const PamClientSession&);
public:
typedef std::vector<std::string> StringVector;
using StringSet = std::set<std::string>;
static PamClientSession* create(const PamInstance& inst);
~PamClientSession();
int authenticate(DCB* client);
bool extract(DCB* dcb, GWBUF* read_buffer);
private:
PamClientSession(sqlite3* dbhandle, const PamInstance& instance);
void get_pam_user_services(const DCB* dcb, const MYSQL_session* session, StringVector* services_out);
void get_pam_user_services(const DCB* dcb, const MYSQL_session* session, StringSet* services_out);
maxscale::Buffer create_auth_change_packet() const;
enum class State