Replace get_users implementation with new version
The get_users function now combines the functionality of the old get_users and get_all_users. This removes large parts of similar code. Removed the listener resources as MySQLAuth was the only one that used it.
This commit is contained in:
@ -742,102 +742,6 @@ gw_check_mysql_scramble_data(DCB *dcb,
|
||||
return (0 == memcmp(password, check_hash, SHA_DIGEST_LENGTH)) ?
|
||||
MXS_AUTH_SUCCEEDED : MXS_AUTH_FAILED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief If the client connection specifies a database, check existence
|
||||
*
|
||||
* The client can specify a default database, but if so, it must be one
|
||||
* that exists. This function is chained from the previous one, and will
|
||||
* amend the given return code if it is previously showing success.
|
||||
*
|
||||
* @param dcb Request handler DCB connected to the client
|
||||
* @param database A string containing the database name
|
||||
* @param auth_ret The authentication status prior to calling this function.
|
||||
* @return Authentication status
|
||||
* @note Authentication status codes are defined in maxscale/protocol/mysql.h
|
||||
*/
|
||||
int
|
||||
check_db_name_after_auth(DCB *dcb, char *database, int auth_ret)
|
||||
{
|
||||
int db_exists = -1;
|
||||
|
||||
/* check for database name and possible match in resource hashtable */
|
||||
if (database && strlen(database))
|
||||
{
|
||||
/* if database names are loaded we can check if db name exists */
|
||||
if (dcb->listener->resources != NULL)
|
||||
{
|
||||
if (hashtable_fetch(dcb->listener->resources, database))
|
||||
{
|
||||
db_exists = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
db_exists = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if database names are not loaded we don't allow connection with db name*/
|
||||
db_exists = -1;
|
||||
}
|
||||
|
||||
if (db_exists == 0 && auth_ret == MXS_AUTH_SUCCEEDED)
|
||||
{
|
||||
auth_ret = MXS_AUTH_FAILED_DB;
|
||||
}
|
||||
|
||||
if (db_exists < 0 && auth_ret == MXS_AUTH_SUCCEEDED)
|
||||
{
|
||||
auth_ret = MXS_AUTH_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return auth_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to easily call authentication and database checks.
|
||||
*
|
||||
* The two functions are called one after the other, with the return from
|
||||
* the first passed to the second. For convenience and clarity this function
|
||||
* combines the calls.
|
||||
*
|
||||
* @param dcb Request handler DCB connected to the client
|
||||
* @param auth_token A string of bytes containing the authentication token
|
||||
* @param auth_token_len An integer, the length of the preceding parameter
|
||||
* @param protocol The protocol structure for the connection
|
||||
* @param username String containing username
|
||||
* @param stage1_hash A password hash for authentication
|
||||
* @param database A string containing the name for the default database
|
||||
* @return Authentication status
|
||||
* @note Authentication status codes are defined in maxscale/protocol/mysql.h
|
||||
*/
|
||||
static int combined_auth_check(
|
||||
DCB *dcb,
|
||||
uint8_t *auth_token,
|
||||
size_t auth_token_len,
|
||||
MySQLProtocol *protocol,
|
||||
char *username,
|
||||
uint8_t *stage1_hash,
|
||||
char *database
|
||||
)
|
||||
{
|
||||
int auth_ret;
|
||||
|
||||
auth_ret = gw_check_mysql_scramble_data(dcb,
|
||||
auth_token,
|
||||
auth_token_len,
|
||||
protocol->scramble,
|
||||
sizeof(protocol->scramble),
|
||||
username,
|
||||
stage1_hash);
|
||||
|
||||
/* check for database name match in resource hashtable */
|
||||
auth_ret = check_db_name_after_auth(dcb, database, auth_ret);
|
||||
return auth_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free the client data pointed to by the passed DCB.
|
||||
*
|
||||
|
Reference in New Issue
Block a user