MXS-1220: Add old diagnostic interface for monitors and authenticators

Added back the old diagnostic entry point in the monitor and authenticator
interfaces.
This commit is contained in:
Markus Mäkelä
2017-04-21 12:14:12 +03:00
committed by Markus Mäkelä
parent 07175ed86b
commit b1294f083c
14 changed files with 158 additions and 16 deletions

View File

@ -167,6 +167,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* No destroy entry point */
cdc_replace_users, /* Load CDC users */
users_default_diagnostic, /* Default diagnostic */
users_default_diagnostic_json, /* Default diagnostic */
NULL /* No user reauthentication */
};

View File

@ -666,6 +666,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
gssapi_auth_free, /* Free authenticator data */
gssapi_auth_load_users, /* Load database users */
users_default_diagnostic, /* Default user diagnostic */
users_default_diagnostic_json, /* Default user diagnostic */
NULL /* No user reauthentication */
};

View File

@ -278,6 +278,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
gssapi_backend_auth_free, /* Free authenticator data */
NULL, /* Load users from backend databases */
NULL, /* No diagnostic */
NULL,
NULL /* No user reauthentication */
};

View File

@ -68,6 +68,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* No destroy entry point */
users_default_loadusers, /* Load generic users */
users_default_diagnostic, /* Default user diagnostic */
users_default_diagnostic_json, /* Default user diagnostic */
NULL /* No user reauthentication */
};

View File

@ -62,6 +62,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* No destroy entry point */
users_default_loadusers, /* Load generic users */
users_default_diagnostic, /* Default user diagnostic */
users_default_diagnostic_json, /* Default user diagnostic */
NULL /* No user reauthentication */
};

View File

@ -58,7 +58,8 @@ static int mysql_auth_set_client_data(
MySQLProtocol *protocol,
GWBUF *buffer);
json_t* mysql_auth_diagnostic(const SERV_LISTENER *port);
void mysql_auth_diagnostic(DCB *dcb, SERV_LISTENER *port);
json_t* mysql_auth_diagnostic_json(const SERV_LISTENER *port);
int mysql_auth_reauthenticate(DCB *dcb, const char *user,
uint8_t *token, size_t token_len,
@ -85,6 +86,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
mysql_auth_destroy, /* Destroy entry point */
mysql_auth_load_users, /* Load users from backend databases */
mysql_auth_diagnostic,
mysql_auth_diagnostic_json,
mysql_auth_reauthenticate /* Handle COM_CHANGE_USER */
};
@ -681,6 +683,30 @@ int mysql_auth_reauthenticate(DCB *dcb, const char *user,
}
int diag_cb(void *data, int columns, char **row, char **field_names)
{
DCB *dcb = (DCB*)data;
dcb_printf(dcb, "%s@%s ", row[0], row[1]);
return 0;
}
void mysql_auth_diagnostic(DCB *dcb, SERV_LISTENER *port)
{
dcb_printf(dcb, "User names: ");
MYSQL_AUTH *instance = (MYSQL_AUTH*)port->auth_instance;
char *err;
if (sqlite3_exec(instance->handle, "SELECT user, host FROM " MYSQLAUTH_USERS_TABLE_NAME,
diag_cb, dcb, &err) != SQLITE_OK)
{
dcb_printf(dcb, "Failed to print users: %s\n", err);
MXS_ERROR("Failed to print users: %s", err);
sqlite3_free(err);
}
dcb_printf(dcb, "\n");
}
int diag_cb_json(void *data, int columns, char **row, char **field_names)
{
json_t* obj = json_object();
json_object_set_new(obj, "user", json_string(row[0]));
@ -691,7 +717,7 @@ int diag_cb(void *data, int columns, char **row, char **field_names)
return 0;
}
json_t* mysql_auth_diagnostic(const SERV_LISTENER *port)
json_t* mysql_auth_diagnostic_json(const SERV_LISTENER *port)
{
json_t* rval = json_array();

View File

@ -171,6 +171,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
auth_backend_destroy, /* Destroy authenticator */
NULL, /* We don't need to load users */
NULL, /* No diagnostic */
NULL,
NULL /* No user reauthentication */
};

View File

@ -64,6 +64,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* No destroy entry point */
users_default_loadusers, /* Load generic users */
NULL, /* No diagnostic */
NULL,
NULL /* No user reauthentication */
};

View File

@ -61,6 +61,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* No destroy entry point */
users_default_loadusers, /* Load generic users */
NULL, /* No diagnostic */
NULL,
NULL /* No user reauthentication */
};