MXS-2196: Take Listener into use
This commit is contained in:
parent
330719c8f9
commit
a10b6c2e89
@ -3863,13 +3863,13 @@ int create_new_listener(CONFIG_CONTEXT* obj)
|
||||
address = "";
|
||||
}
|
||||
|
||||
if (auto l = service_find_listener(service, socket, address, socket ? 0 : atoi(port)))
|
||||
if (auto l = service_find_listener(service, socket ? socket : "", address, socket ? 0 : atoi(port)))
|
||||
{
|
||||
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "
|
||||
"listener '%s' already listens on the %s %s.",
|
||||
obj->object,
|
||||
service->name,
|
||||
l->name.c_str(),
|
||||
l->name(),
|
||||
socket ? "socket" : "port",
|
||||
socket ? socket : port);
|
||||
return 1;
|
||||
|
@ -978,16 +978,16 @@ bool runtime_create_listener(Service* service,
|
||||
proto = "mariadbclient";
|
||||
}
|
||||
|
||||
if (auth && strcasecmp(auth, CN_DEFAULT) == 0)
|
||||
if (!auth || strcasecmp(auth, CN_DEFAULT) == 0)
|
||||
{
|
||||
/** Set auth to NULL so the protocol default authenticator is used */
|
||||
auth = NULL;
|
||||
/** Use protocol default authenticator*/
|
||||
auth = "";
|
||||
}
|
||||
|
||||
if (auth_opt && strcasecmp(auth_opt, CN_DEFAULT) == 0)
|
||||
if (!auth_opt || strcasecmp(auth_opt, CN_DEFAULT) == 0)
|
||||
{
|
||||
/** Don't pass options to the authenticator */
|
||||
auth_opt = NULL;
|
||||
auth_opt = "";
|
||||
}
|
||||
|
||||
unsigned short u_port = atoi(port);
|
||||
@ -995,7 +995,7 @@ bool runtime_create_listener(Service* service,
|
||||
|
||||
std::lock_guard<std::mutex> guard(crt_lock);
|
||||
|
||||
if (!serviceHasListener(service, name, proto, addr, u_port))
|
||||
if (!listener_find(name) && !service_find_listener(service, "", addr, u_port))
|
||||
{
|
||||
SSL_LISTENER* ssl = NULL;
|
||||
|
||||
|
@ -2230,8 +2230,8 @@ static int dcb_create_SSL(DCB* dcb, SSL_LISTENER* ssl)
|
||||
*/
|
||||
int dcb_accept_SSL(DCB* dcb)
|
||||
{
|
||||
if ((NULL == dcb->listener || NULL == dcb->listener->ssl)
|
||||
|| (NULL == dcb->ssl && dcb_create_SSL(dcb, dcb->listener->ssl) != 0))
|
||||
if ((NULL == dcb->listener || NULL == dcb->listener->ssl())
|
||||
|| (NULL == dcb->ssl && dcb_create_SSL(dcb, dcb->listener->ssl()) != 0))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -2451,10 +2451,11 @@ DCB* dcb_accept(DCB* dcb)
|
||||
INET6_ADDRSTRLEN);
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&client_dcb->func, protocol_funcs, sizeof(MXS_PROTOCOL));
|
||||
if (!dcb->listener->authenticator.empty())
|
||||
if (*dcb->listener->authenticator())
|
||||
{
|
||||
authenticator_name = dcb->listener->authenticator.c_str();
|
||||
authenticator_name = dcb->listener->authenticator();
|
||||
}
|
||||
else if (client_dcb->func.auth_default != NULL)
|
||||
{
|
||||
@ -2476,7 +2477,7 @@ DCB* dcb_accept(DCB* dcb)
|
||||
/** Allocate DCB specific authentication data */
|
||||
if (client_dcb->authfunc.create
|
||||
&& (client_dcb->authenticator_data =
|
||||
client_dcb->authfunc.create(client_dcb->listener->auth_instance)) == NULL)
|
||||
client_dcb->authfunc.create(client_dcb->listener->auth_instance())) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to create authenticator for client DCB");
|
||||
dcb_close(client_dcb);
|
||||
@ -2908,7 +2909,7 @@ void dcb_process_idle_sessions(int thr)
|
||||
if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER)
|
||||
{
|
||||
mxb_assert(dcb->listener);
|
||||
SERVICE* service = dcb->listener->service;
|
||||
SERVICE* service = dcb->listener->service();
|
||||
|
||||
if (service->conn_idle_timeout && dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
|
@ -347,25 +347,10 @@ bool serviceLaunchListener(Service* service, const SListener& port);
|
||||
* @return True if service has the listener
|
||||
*/
|
||||
SListener service_find_listener(Service* service,
|
||||
const char* socket,
|
||||
const char* address,
|
||||
const std::string& socket,
|
||||
const std::string& address,
|
||||
unsigned short port);
|
||||
|
||||
/**
|
||||
* @brief Check if a service has a listener
|
||||
*
|
||||
* @param service Service to check
|
||||
* @param protocol Listener protocol
|
||||
* @param address Listener address
|
||||
* @param port Listener port
|
||||
* @return True if service has the listener
|
||||
*/
|
||||
bool serviceHasListener(Service* service,
|
||||
const char* name,
|
||||
const char* protocol,
|
||||
const char* address,
|
||||
unsigned short port);
|
||||
|
||||
/**
|
||||
* @brief Check if a MaxScale service listens on a port
|
||||
*
|
||||
|
@ -238,8 +238,8 @@ Service::~Service()
|
||||
|
||||
for (const auto& tmp : listener_find_by_service(this))
|
||||
{
|
||||
mxb_assert(!tmp->active || maxscale_teardown_in_progress());
|
||||
listener_free(listener_find(tmp->name));
|
||||
mxb_assert(!tmp->is_active() || maxscale_teardown_in_progress());
|
||||
listener_free(listener_find(tmp->name()));
|
||||
}
|
||||
|
||||
if (router && router_instance && router->destroyInstance)
|
||||
@ -546,58 +546,28 @@ bool service_remove_listener(Service* service, const char* target)
|
||||
}
|
||||
|
||||
SListener service_find_listener(Service* service,
|
||||
const char* socket,
|
||||
const char* address,
|
||||
const std::string& socket,
|
||||
const std::string& address,
|
||||
unsigned short port)
|
||||
{
|
||||
SListener rval;
|
||||
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
if (port == listener->port)
|
||||
if (port == listener->port() && (listener->address() == address || listener->address() == socket))
|
||||
{
|
||||
if ((!address && listener->address.empty()) || listener->address == address
|
||||
|| (!socket && listener->address.empty()) || listener->address == socket)
|
||||
{
|
||||
return listener;
|
||||
}
|
||||
rval = listener;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a protocol/port pair is part of the service
|
||||
*
|
||||
* @param service The service
|
||||
* @param protocol The name of the protocol module
|
||||
* @param address The address to listen on
|
||||
* @param port The port to listen on
|
||||
* @return True if the protocol/port is already part of the service
|
||||
*/
|
||||
bool serviceHasListener(Service* service,
|
||||
const char* name,
|
||||
const char* protocol,
|
||||
const char* address,
|
||||
unsigned short port)
|
||||
{
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
if (listener->port == port)
|
||||
{
|
||||
if ((!address && listener->address.empty()) || listener->address == address)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool service_has_named_listener(Service* service, const char* name)
|
||||
{
|
||||
auto listener = listener_find(name);
|
||||
return listener && listener->service == service;
|
||||
return listener && listener->service() == service;
|
||||
}
|
||||
|
||||
bool service_can_be_destroyed(Service* service)
|
||||
@ -1094,12 +1064,12 @@ void dListListeners(DCB* dcb)
|
||||
{
|
||||
dcb_printf(dcb,
|
||||
"%-20s | %-19s | %-18s | %-15s | %5d | %s\n",
|
||||
listener->name.c_str(),
|
||||
listener->name(),
|
||||
service->name,
|
||||
listener->protocol.c_str(),
|
||||
(listener && !listener->address.empty()) ? listener->address.c_str() : "*",
|
||||
listener->port,
|
||||
listener_state_to_string(listener));
|
||||
listener->protocol(),
|
||||
(listener && *listener->address()) ? listener->address() : "*",
|
||||
listener->port(),
|
||||
listener->state());
|
||||
}
|
||||
}
|
||||
if (!this_unit.services.empty())
|
||||
@ -1316,8 +1286,8 @@ std::unique_ptr<ResultSet> serviceGetListenerList()
|
||||
{
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
set->add_row({service->name, listener->protocol, listener->address,
|
||||
std::to_string(listener->port), listener_state_to_string(listener)});
|
||||
set->add_row({service->name, listener->protocol(), listener->address(),
|
||||
std::to_string(listener->port()), listener->state()});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1623,7 +1593,7 @@ bool service_port_is_used(unsigned short port)
|
||||
{
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
if (listener->port == port)
|
||||
if (listener->port() == port)
|
||||
{
|
||||
rval = true;
|
||||
break;
|
||||
@ -1694,7 +1664,7 @@ static json_t* service_all_listeners_json_data(const SERVICE* service)
|
||||
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
json_array_append_new(arr, listener_to_json(listener));
|
||||
json_array_append_new(arr, listener->to_json());
|
||||
}
|
||||
|
||||
return arr;
|
||||
@ -1704,9 +1674,9 @@ static json_t* service_listener_json_data(const SERVICE* service, const char* na
|
||||
{
|
||||
auto listener = listener_find(name);
|
||||
|
||||
if (listener && listener->service == service)
|
||||
if (listener && listener->service() == service)
|
||||
{
|
||||
return listener_to_json(listener);
|
||||
return listener->to_json();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -54,7 +54,7 @@ int ssl_authenticate_client(DCB* dcb, bool is_capable)
|
||||
const char* remote = dcb->remote ? dcb->remote : "";
|
||||
const char* service = (dcb->service && dcb->service->name) ? dcb->service->name : "";
|
||||
|
||||
if (NULL == dcb->listener || NULL == dcb->listener->ssl)
|
||||
if (NULL == dcb->listener || NULL == dcb->listener->ssl())
|
||||
{
|
||||
/* Not an SSL connection on account of listener configuration */
|
||||
return SSL_AUTH_CHECKS_OK;
|
||||
@ -134,7 +134,7 @@ bool ssl_is_connection_healthy(DCB* dcb)
|
||||
* more to be done.
|
||||
*/
|
||||
return NULL == dcb->listener
|
||||
|| NULL == dcb->listener->ssl
|
||||
|| NULL == dcb->listener->ssl()
|
||||
|| dcb->ssl_state == SSL_ESTABLISHED;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ bool ssl_check_data_to_process(DCB* dcb)
|
||||
*/
|
||||
bool ssl_required_by_dcb(DCB* dcb)
|
||||
{
|
||||
return NULL != dcb->listener && NULL != dcb->listener->ssl;
|
||||
return NULL != dcb->listener && NULL != dcb->listener->ssl();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ bool ssl_required_by_dcb(DCB* dcb)
|
||||
bool ssl_required_but_not_negotiated(DCB* dcb)
|
||||
{
|
||||
return NULL != dcb->listener
|
||||
&& NULL != dcb->listener->ssl
|
||||
&& NULL != dcb->listener->ssl()
|
||||
&& SSL_HANDSHAKE_UNKNOWN == dcb->ssl_state;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static int test1()
|
||||
NULL,
|
||||
NULL),
|
||||
"Add Protocol should succeed");
|
||||
mxb_assert_message(0 != serviceHasListener(service, "TestProtocol", "mariadbclient", "localhost", 9876),
|
||||
mxb_assert_message(service_find_listener(service, "", "localhost", 9876),
|
||||
"Service should have new protocol as requested");
|
||||
|
||||
return 0;
|
||||
|
@ -328,21 +328,21 @@ json_t* users_diagnostic_json(USERS* users)
|
||||
|
||||
void users_default_diagnostic(DCB* dcb, Listener* port)
|
||||
{
|
||||
if (port->users)
|
||||
if (port->users())
|
||||
{
|
||||
users_diagnostic(dcb, port->users);
|
||||
users_diagnostic(dcb, port->users());
|
||||
}
|
||||
}
|
||||
|
||||
json_t* users_default_diagnostic_json(const Listener* port)
|
||||
{
|
||||
return port->users ? users_diagnostic_json(port->users) : json_array();
|
||||
return port->users() ? users_diagnostic_json(port->users()) : json_array();
|
||||
}
|
||||
|
||||
int users_default_loadusers(Listener* port)
|
||||
{
|
||||
users_free(port->users);
|
||||
port->users = users_alloc();
|
||||
users_free(port->users());
|
||||
port->set_users(users_alloc());
|
||||
return MXS_AUTH_LOADUSERS_OK;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ static int httpd_read_event(DCB* dcb)
|
||||
/** If listener->authenticator is the default authenticator, it means that
|
||||
* we don't need to check the user credentials. All other authenticators
|
||||
* cause a 401 Unauthorized to be returned on the first try. */
|
||||
bool auth_ok = httpd_default_auth() == dcb->listener->authenticator;
|
||||
bool auth_ok = httpd_default_auth() == std::string(dcb->listener->authenticator());
|
||||
|
||||
/**
|
||||
* Get the request headers
|
||||
|
@ -269,10 +269,10 @@ LocalClient* LocalClient::create(MYSQL_session* session, MySQLProtocol* proto, S
|
||||
|
||||
for (const auto& listener : listener_find_by_service(service))
|
||||
{
|
||||
if (listener->port > 0)
|
||||
if (listener->port() > 0)
|
||||
{
|
||||
/** Pick the first network listener */
|
||||
rval = create(session, proto, "127.0.0.1", listener->port);
|
||||
rval = create(session, proto, "127.0.0.1", listener->port());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ static void check_packet(DCB* dcb, GWBUF* buf, int bytes)
|
||||
if (bytes == MYSQL_AUTH_PACKET_BASE_SIZE)
|
||||
{
|
||||
/** This is an SSL request packet */
|
||||
mxb_assert(dcb->listener->ssl);
|
||||
mxb_assert(dcb->listener->ssl());
|
||||
mxb_assert(buflen == bytes && pktlen >= buflen);
|
||||
}
|
||||
else
|
||||
@ -1436,11 +1436,11 @@ static void gw_process_one_new_client(DCB* client_dcb)
|
||||
// Move the rest of the initialization process to the owning worker
|
||||
mxs::RoutingWorker* worker = static_cast<mxs::RoutingWorker*>(client_dcb->poll.owner);
|
||||
|
||||
worker->execute([=](){
|
||||
client_dcb->protocol = mysql_protocol_init(client_dcb, client_dcb->fd);
|
||||
MXS_ABORT_IF_NULL(client_dcb->protocol);
|
||||
MySQLSendHandshake(client_dcb);
|
||||
}, mxs::RoutingWorker::EXECUTE_AUTO);
|
||||
worker->execute([=]() {
|
||||
client_dcb->protocol = mysql_protocol_init(client_dcb, client_dcb->fd);
|
||||
MXS_ABORT_IF_NULL(client_dcb->protocol);
|
||||
MySQLSendHandshake(client_dcb);
|
||||
}, mxs::RoutingWorker::EXECUTE_AUTO);
|
||||
|
||||
MXS_DEBUG("Added dcb %p for fd %d to epoll set.",
|
||||
client_dcb,
|
||||
|
Loading…
x
Reference in New Issue
Block a user