MXS-2196: Take Listener into use
This commit is contained in:
@ -219,7 +219,7 @@ static int cdc_auth_check(DCB* dcb,
|
||||
{
|
||||
int rval = CDC_STATE_AUTH_FAILED;
|
||||
|
||||
if (dcb->listener->users)
|
||||
if (dcb->listener->users())
|
||||
{
|
||||
/* compute SHA1 of auth_data */
|
||||
uint8_t sha1_step1[SHA_DIGEST_LENGTH] = "";
|
||||
@ -228,7 +228,7 @@ static int cdc_auth_check(DCB* dcb,
|
||||
gw_sha1_str(auth_data, SHA_DIGEST_LENGTH, sha1_step1);
|
||||
gw_bin2hex(hex_step1, sha1_step1, SHA_DIGEST_LENGTH);
|
||||
|
||||
if (users_auth(dcb->listener->users, username, hex_step1))
|
||||
if (users_auth(dcb->listener->users(), username, hex_step1))
|
||||
{
|
||||
rval = CDC_STATE_AUTH_OK;
|
||||
}
|
||||
@ -439,7 +439,7 @@ static void cdc_auth_free_client_data(DCB* dcb)
|
||||
*/
|
||||
static int cdc_set_service_user(Listener* listener)
|
||||
{
|
||||
SERVICE* service = listener->service;
|
||||
SERVICE* service = listener->service();
|
||||
char* dpwd = NULL;
|
||||
char* newpasswd = NULL;
|
||||
const char* service_user = NULL;
|
||||
@ -472,7 +472,7 @@ static int cdc_set_service_user(Listener* listener)
|
||||
const char* user;
|
||||
const char* password;
|
||||
serviceGetUser(service, &user, &password);
|
||||
users_add(listener->users, user, newpasswd, USER_ACCOUNT_ADMIN);
|
||||
users_add(listener->users(), user, newpasswd, USER_ACCOUNT_ADMIN);
|
||||
|
||||
MXS_FREE(newpasswd);
|
||||
MXS_FREE(dpwd);
|
||||
@ -550,7 +550,7 @@ int cdc_replace_users(Listener* listener)
|
||||
PATH_MAX,
|
||||
"%s/%s/%s",
|
||||
get_datadir(),
|
||||
listener->service->name,
|
||||
listener->service()->name,
|
||||
CDC_USERS_FILENAME);
|
||||
|
||||
int i = cdc_read_users(newusers, path);
|
||||
@ -559,11 +559,11 @@ int cdc_replace_users(Listener* listener)
|
||||
if (i > 0)
|
||||
{
|
||||
/** Successfully loaded at least one user */
|
||||
oldusers = listener->users;
|
||||
listener->users = newusers;
|
||||
oldusers = listener->users();
|
||||
listener->set_users(newusers);
|
||||
rc = MXS_AUTH_LOADUSERS_OK;
|
||||
}
|
||||
else if (listener->users)
|
||||
else if (listener->users())
|
||||
{
|
||||
/** Failed to load users, use the old users table */
|
||||
users_free(newusers);
|
||||
@ -571,7 +571,7 @@ int cdc_replace_users(Listener* listener)
|
||||
else
|
||||
{
|
||||
/** No existing users, use the new empty users table */
|
||||
listener->users = newusers;
|
||||
listener->set_users(newusers);
|
||||
}
|
||||
|
||||
cdc_set_service_user(listener);
|
||||
|
@ -491,7 +491,7 @@ int gssapi_auth_authenticate(DCB* dcb)
|
||||
{
|
||||
int rval = MXS_AUTH_FAILED;
|
||||
gssapi_auth_t* auth = (gssapi_auth_t*)dcb->authenticator_data;
|
||||
GSSAPI_INSTANCE* instance = (GSSAPI_INSTANCE*)dcb->listener->auth_instance;
|
||||
GSSAPI_INSTANCE* instance = (GSSAPI_INSTANCE*)dcb->listener->auth_instance();
|
||||
|
||||
if (auth->state == GSSAPI_AUTH_INIT)
|
||||
{
|
||||
@ -627,15 +627,15 @@ int gssapi_auth_load_users(Listener* listener)
|
||||
const char* user;
|
||||
const char* password;
|
||||
int rval = MXS_AUTH_LOADUSERS_ERROR;
|
||||
GSSAPI_INSTANCE* inst = (GSSAPI_INSTANCE*)listener->auth_instance;
|
||||
serviceGetUser(listener->service, &user, &password);
|
||||
GSSAPI_INSTANCE* inst = (GSSAPI_INSTANCE*)listener->auth_instance();
|
||||
serviceGetUser(listener->service(), &user, &password);
|
||||
char* pw;
|
||||
|
||||
if ((pw = decrypt_password(password)))
|
||||
{
|
||||
bool no_active_servers = true;
|
||||
|
||||
for (SERVER_REF* servers = listener->service->dbref; servers; servers = servers->next)
|
||||
for (SERVER_REF* servers = listener->service()->dbref; servers; servers = servers->next)
|
||||
{
|
||||
if (!SERVER_REF_IS_ACTIVE(servers) || !server_is_active(servers->server))
|
||||
{
|
||||
|
@ -1123,7 +1123,7 @@ int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service,
|
||||
service->enable_root,
|
||||
category);
|
||||
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance();
|
||||
sqlite3* handle = get_handle(instance);
|
||||
int users = 0;
|
||||
|
||||
@ -1182,7 +1182,7 @@ static int get_users(Listener* listener, bool skip_local)
|
||||
{
|
||||
const char* service_user = NULL;
|
||||
const char* service_passwd = NULL;
|
||||
SERVICE* service = listener->service;
|
||||
SERVICE* service = listener->service();
|
||||
|
||||
serviceGetUser(service, &service_user, &service_passwd);
|
||||
|
||||
@ -1194,7 +1194,7 @@ static int get_users(Listener* listener, bool skip_local)
|
||||
}
|
||||
|
||||
/** Delete the old users */
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance();
|
||||
sqlite3* handle = get_handle(instance);
|
||||
delete_mysql_users(handle);
|
||||
|
||||
|
@ -293,7 +293,7 @@ static int mysql_auth_authenticate(DCB* dcb)
|
||||
client_data->user,
|
||||
client_data->db);
|
||||
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
|
||||
MySQLProtocol* protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
auth_ret = validate_mysql_user(instance,
|
||||
dcb,
|
||||
@ -558,7 +558,7 @@ static bool add_service_user(Listener* port)
|
||||
const char* password = NULL;
|
||||
bool rval = false;
|
||||
|
||||
serviceGetUser(port->service, &user, &password);
|
||||
serviceGetUser(port->service(), &user, &password);
|
||||
|
||||
char* pw;
|
||||
|
||||
@ -568,7 +568,7 @@ static bool add_service_user(Listener* port)
|
||||
|
||||
if (newpw)
|
||||
{
|
||||
MYSQL_AUTH* inst = (MYSQL_AUTH*)port->auth_instance;
|
||||
MYSQL_AUTH* inst = (MYSQL_AUTH*)port->auth_instance();
|
||||
sqlite3* handle = get_handle(inst);
|
||||
add_mysql_user(handle, user, "%", "", "Y", newpw);
|
||||
add_mysql_user(handle, user, "localhost", "", "Y", newpw);
|
||||
@ -579,7 +579,7 @@ static bool add_service_user(Listener* port)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("[%s] Failed to decrypt service user password.", port->service->name);
|
||||
MXS_ERROR("[%s] Failed to decrypt service user password.", port->service()->name);
|
||||
}
|
||||
|
||||
return rval;
|
||||
@ -610,13 +610,13 @@ static bool service_has_servers(SERVICE* service)
|
||||
static int mysql_auth_load_users(Listener* port)
|
||||
{
|
||||
int rc = MXS_AUTH_LOADUSERS_OK;
|
||||
SERVICE* service = port->listener->service;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance;
|
||||
SERVICE* service = port->service();
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
|
||||
bool first_load = false;
|
||||
|
||||
if (should_check_permissions(instance))
|
||||
{
|
||||
if (!check_service_permissions(port->service))
|
||||
if (!check_service_permissions(port->service()))
|
||||
{
|
||||
return MXS_AUTH_LOADUSERS_FATAL;
|
||||
}
|
||||
@ -635,9 +635,9 @@ static int mysql_auth_load_users(Listener* port)
|
||||
{
|
||||
MXS_ERROR("[%s] Unable to load users for listener %s listening at [%s]:%d.",
|
||||
service->name,
|
||||
port->name.c_str(),
|
||||
!port->address.empty() ? port->address.c_str() : "::",
|
||||
port->port);
|
||||
port->name(),
|
||||
*port->address() ? port->address() : "::",
|
||||
port->port());
|
||||
}
|
||||
|
||||
if (instance->inject_service_user)
|
||||
@ -646,7 +646,7 @@ static int mysql_auth_load_users(Listener* port)
|
||||
* if loading of the users fails */
|
||||
if (!add_service_user(port))
|
||||
{
|
||||
MXS_ERROR("[%s] Failed to inject service user.", port->service->name);
|
||||
MXS_ERROR("[%s] Failed to inject service user.", port->service()->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -673,7 +673,7 @@ static int mysql_auth_load_users(Listener* port)
|
||||
}
|
||||
else if (loaded > 0 && first_load)
|
||||
{
|
||||
MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s.", service->name, loaded, port->name.c_str());
|
||||
MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s.", service->name, loaded, port->name());
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -697,7 +697,7 @@ int mysql_auth_reauthenticate(DCB* dcb,
|
||||
temp.auth_token = token;
|
||||
temp.auth_token_len = token_len;
|
||||
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
|
||||
int rc = validate_mysql_user(instance, dcb, &temp, scramble, scramble_len);
|
||||
|
||||
if (rc != MXS_AUTH_SUCCEEDED && service_refresh_users(dcb->service) == 0)
|
||||
@ -723,7 +723,7 @@ int diag_cb(void* data, int columns, char** row, char** field_names)
|
||||
|
||||
void mysql_auth_diagnostic(DCB* dcb, Listener* port)
|
||||
{
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
|
||||
sqlite3* handle = get_handle(instance);
|
||||
char* err;
|
||||
|
||||
@ -754,7 +754,7 @@ json_t* mysql_auth_diagnostic_json(const Listener* port)
|
||||
{
|
||||
json_t* rval = json_array();
|
||||
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance;
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
|
||||
char* err;
|
||||
sqlite3* handle = get_handle(instance);
|
||||
|
||||
|
@ -136,19 +136,19 @@ static void pam_auth_free_data(DCB* dcb)
|
||||
*/
|
||||
static int pam_auth_load_users(Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
return inst->load_users(listener->service);
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
|
||||
return inst->load_users(listener->service());
|
||||
}
|
||||
|
||||
static void pam_auth_diagnostic(DCB* dcb, Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
|
||||
inst->diagnostic(dcb);
|
||||
}
|
||||
|
||||
static json_t* pam_auth_diagnostic_json(const Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
|
||||
return inst->diagnostic_json();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user