MXS-1842 Compile all authenticators as C++
Minimal changes, only what is needed to compile.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
if(SQLITE_VERSION VERSION_LESS 3.3)
|
||||
message(FATAL_ERROR "SQLite version 3.3 or higher is required")
|
||||
else()
|
||||
add_library(mysqlauth SHARED mysql_auth.c dbusers.c)
|
||||
add_library(mysqlauth SHARED mysql_auth.cc dbusers.cc)
|
||||
target_link_libraries(mysqlauth maxscale-common mysqlcommon)
|
||||
set_target_properties(mysqlauth PROPERTIES VERSION "1.0.0")
|
||||
install_module(mysqlauth core)
|
||||
|
||||
@ -62,7 +62,7 @@ static char* get_new_users_query(const char *server_version, bool include_root)
|
||||
const char *with_root = include_root ? "" : " AND u.user NOT IN ('root')";
|
||||
|
||||
size_t n_bytes = snprintf(NULL, 0, NEW_LOAD_DBUSERS_QUERY, password, with_root, password, with_root);
|
||||
char *rval = MXS_MALLOC(n_bytes + 1);
|
||||
char *rval = static_cast<char*>(MXS_MALLOC(n_bytes + 1));
|
||||
|
||||
if (rval)
|
||||
{
|
||||
@ -536,12 +536,12 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
mxs_mysql_set_server_version(mysql, server);
|
||||
}
|
||||
|
||||
const char *template = "SELECT user, host, %s, Select_priv FROM mysql.user limit 1";
|
||||
const char* format = "SELECT user, host, %s, Select_priv FROM mysql.user limit 1";
|
||||
const char* query_pw = strstr(server->version_string, "5.7.") ?
|
||||
MYSQL57_PASSWORD : MYSQL_PASSWORD;
|
||||
char query[strlen(template) + strlen(query_pw) + 1];
|
||||
char query[strlen(format) + strlen(query_pw) + 1];
|
||||
bool rval = true;
|
||||
sprintf(query, template, query_pw);
|
||||
sprintf(query, format, query_pw);
|
||||
|
||||
if (mxs_mysql_query(mysql, query) != 0)
|
||||
{
|
||||
@ -66,6 +66,9 @@ int mysql_auth_reauthenticate(DCB *dcb, const char *user,
|
||||
uint8_t *token, size_t token_len,
|
||||
uint8_t *scramble, size_t scramble_len,
|
||||
uint8_t *output_token, size_t output_token_len);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -110,6 +113,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool open_instance_database(const char *path, sqlite3 **handle)
|
||||
{
|
||||
int rc = sqlite3_open_v2(path, handle, db_flags, NULL);
|
||||
@ -170,9 +175,10 @@ static bool should_check_permissions(MYSQL_AUTH* instance)
|
||||
*/
|
||||
static void* mysql_auth_init(char **options)
|
||||
{
|
||||
MYSQL_AUTH *instance = MXS_MALLOC(sizeof(*instance));
|
||||
MYSQL_AUTH *instance = static_cast<MYSQL_AUTH*>(MXS_MALLOC(sizeof(*instance)));
|
||||
|
||||
if (instance && (instance->handles = MXS_CALLOC(config_threadcount(), sizeof(sqlite3*))))
|
||||
if (instance &&
|
||||
(instance->handles = static_cast<sqlite3**>(MXS_CALLOC(config_threadcount(), sizeof(sqlite3*)))))
|
||||
{
|
||||
bool error = false;
|
||||
instance->cache_dir = NULL;
|
||||
@ -404,7 +410,7 @@ mysql_auth_set_client_data(
|
||||
MySQLProtocol *protocol,
|
||||
GWBUF *buffer)
|
||||
{
|
||||
size_t client_auth_packet_size = gwbuf_length(buffer);
|
||||
int client_auth_packet_size = gwbuf_length(buffer);
|
||||
uint8_t client_auth_packet[client_auth_packet_size];
|
||||
gwbuf_copy_data(buffer, 0, client_auth_packet_size, client_auth_packet);
|
||||
|
||||
Reference in New Issue
Block a user