Move dbusers.c out of the core
The dbusers.c was a MySQL protocol specific file which was used directly by some of the modules. Added a new return value for the loadusers authenticator entry point which allows fatal failures to occur when users are loaded. Currently this is only taken into notice when the service is first started. If a listener later returns a fatal error, it is only logged but the service stays in operation. Moved the MySQLAuth authenticator sources and the tests that relate to this module into a subdirectory in the authenticator directory. Eventually, all authenticators could have a subdirectory of their own.
This commit is contained in:
@ -50,7 +50,6 @@
|
||||
#include <maxscale/resultset.h>
|
||||
#include <maxscale/secrets.h>
|
||||
#include <maxscale/users.h>
|
||||
#include <maxscale/dbusers.h>
|
||||
|
||||
|
||||
MODULE_INFO info =
|
||||
@ -69,7 +68,6 @@ static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);
|
||||
static int maxinfo_ping(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);
|
||||
static int maxinfo_execute_query(INFO_INSTANCE *, INFO_SESSION *, char *);
|
||||
static int handle_url(INFO_INSTANCE *instance, INFO_SESSION *router_session, GWBUF *queue);
|
||||
static int maxinfo_add_mysql_user(SERVICE *service);
|
||||
|
||||
|
||||
/* The router entry points */
|
||||
@ -182,13 +180,6 @@ createInstance(SERVICE *service, char **options)
|
||||
instances = inst;
|
||||
spinlock_release(&instlock);
|
||||
|
||||
/*
|
||||
* The following add the service user to service->users via mysql_users_alloc()
|
||||
* password to be used.
|
||||
*/
|
||||
|
||||
maxinfo_add_mysql_user(service);
|
||||
|
||||
return (ROUTER *)inst;
|
||||
}
|
||||
|
||||
@ -736,74 +727,3 @@ handle_url(INFO_INSTANCE *instance, INFO_SESSION *session, GWBUF *queue)
|
||||
gwbuf_free(queue);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the service user to the service->users
|
||||
* via mysql_users_alloc and add_mysql_users_with_host_ipv4
|
||||
* User is added for '%' and 'localhost' hosts
|
||||
*
|
||||
* @param service The service for this router
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
static int
|
||||
maxinfo_add_mysql_user(SERVICE *service)
|
||||
{
|
||||
int rval = 1;
|
||||
char *service_user = NULL;
|
||||
char *service_passwd = NULL;
|
||||
|
||||
if (serviceGetUser(service, &service_user, &service_passwd) == 0)
|
||||
{
|
||||
MXS_ERROR("maxinfo: failed to get service user details");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *dpwd = decryptPassword(service->credentials.authdata);
|
||||
|
||||
if (!dpwd)
|
||||
{
|
||||
MXS_ERROR("maxinfo: decrypt password failed for service user %s", service_user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
SERV_LISTENER *port = service->ports;
|
||||
|
||||
while (port)
|
||||
{
|
||||
while (port && strcmp(port->protocol, "MySQLClient"))
|
||||
{
|
||||
port = port->next;
|
||||
}
|
||||
|
||||
if (port)
|
||||
{
|
||||
port->users = (void *)mysql_users_alloc();
|
||||
|
||||
char *newpasswd = create_hex_sha1_sha1_passwd(dpwd);
|
||||
|
||||
if (!newpasswd)
|
||||
{
|
||||
MXS_ERROR("maxinfo: create hex_sha1_sha1_password failed for "
|
||||
"service user %s", service_user);
|
||||
users_free(port->users);
|
||||
break;
|
||||
}
|
||||
|
||||
/* add service user for % and localhost */
|
||||
add_mysql_users_with_host_ipv4(port->users, service->credentials.name,
|
||||
"%", newpasswd, "Y", "");
|
||||
add_mysql_users_with_host_ipv4(port->users, service->credentials.name,
|
||||
"localhost", newpasswd, "Y", "");
|
||||
rval = 0;
|
||||
MXS_FREE(newpasswd);
|
||||
|
||||
/** Continue processing listeners in case there are multiple
|
||||
* MySQLClient listeners*/
|
||||
port = port->next;
|
||||
}
|
||||
}
|
||||
|
||||
MXS_FREE(dpwd);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user