@ -268,11 +268,13 @@ class ACL_PROXY_USER :public ACL_ACCESS
bool with_grant ;
typedef enum {
MYSQL_PROXY_PRIV_HOST ,
MYSQL_PROXY_PRIV_USER ,
MYSQL_PROXY_PRIV_PROXIED_HOST ,
MYSQL_PROXY_PRIV_PROXIED_USER ,
MYSQL_PROXY_PRIV_WITH_GRANT } old_acl_proxy_users ;
MYSQL_PROXIES_PRIV_HOST ,
MYSQL_PROXIES_PRIV_USER ,
MYSQL_PROXIES_PRIV_PROXIED_HOST ,
MYSQL_PROXIES_PRIV_PROXIED_USER ,
MYSQL_PROXIES_PRIV_WITH_GRANT ,
MYSQL_PROXIES_PRIV_GRANTOR ,
MYSQL_PROXIES_PRIV_TIMESTAMP } old_acl_proxy_users ;
public :
ACL_PROXY_USER ( ) { } ;
@ -308,11 +310,11 @@ public:
void init ( TABLE * table , MEM_ROOT * mem )
{
init ( get_field ( mem , table - > field [ MYSQL_PROXY _PRIV_HOST ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXY _PRIV_USER ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXY _PRIV_PROXIED_HOST ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXY _PRIV_PROXIED_USER ] ) ,
table - > field [ MYSQL_PROXY _PRIV_WITH_GRANT ] - > val_int ( ) ! = 0 ) ;
init ( get_field ( mem , table - > field [ MYSQL_PROXIES _PRIV_HOST ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXIES _PRIV_USER ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXIES _PRIV_PROXIED_HOST ] ) ,
get_field ( mem , table - > field [ MYSQL_PROXIES _PRIV_PROXIED_USER ] ) ,
table - > field [ MYSQL_PROXIES _PRIV_WITH_GRANT ] - > val_int ( ) ! = 0 ) ;
}
bool get_with_grant ( ) { return with_grant ; }
@ -337,7 +339,7 @@ public:
( hostname_requires_resolving ( host . hostname ) | |
hostname_requires_resolving ( proxied_host . hostname ) ) )
{
sql_print_warning ( " 'proxy _priv' entry '%s@%s %s@%s' "
sql_print_warning ( " 'proxes _priv' entry '%s@%s %s@%s' "
" ignored in --skip-name-resolve mode. " ,
proxied_user ? proxied_user : " " ,
proxied_host . hostname ? proxied_host . hostname : " " ,
@ -452,19 +454,19 @@ public:
user - > str ? user - > str : " <NULL> " ,
proxied_host - > str ? proxied_host - > str : " <NULL> " ,
proxied_user - > str ? proxied_user - > str : " <NULL> " ) ) ;
if ( table - > field [ MYSQL_PROXY _PRIV_HOST ] - > store ( host - > str ,
if ( table - > field [ MYSQL_PROXIES _PRIV_HOST ] - > store ( host - > str ,
host - > length ,
system_charset_info ) )
DBUG_RETURN ( TRUE ) ;
if ( table - > field [ MYSQL_PROXY _PRIV_USER ] - > store ( user - > str ,
if ( table - > field [ MYSQL_PROXIES _PRIV_USER ] - > store ( user - > str ,
user - > length ,
system_charset_info ) )
DBUG_RETURN ( TRUE ) ;
if ( table - > field [ MYSQL_PROXY _PRIV_PROXIED_HOST ] - > store ( proxied_host - > str ,
if ( table - > field [ MYSQL_PROXIES _PRIV_PROXIED_HOST ] - > store ( proxied_host - > str ,
proxied_host - > length ,
system_charset_info ) )
DBUG_RETURN ( TRUE ) ;
if ( table - > field [ MYSQL_PROXY _PRIV_PROXIED_USER ] - > store ( proxied_user - > str ,
if ( table - > field [ MYSQL_PROXIES _PRIV_PROXIED_USER ] - > store ( proxied_user - > str ,
proxied_user - > length ,
system_charset_info ) )
DBUG_RETURN ( TRUE ) ;
@ -472,20 +474,25 @@ public:
DBUG_RETURN ( FALSE ) ;
}
static int store_data_record ( TABLE * table ,
const LEX_STRING * host ,
static int store_data_record ( TABLE * table ,
const LEX_STRING * host ,
const LEX_STRING * user ,
const LEX_STRING * proxied_host ,
const LEX_STRING * proxied_host ,
const LEX_STRING * proxied_user ,
bool with_grant )
bool with_grant ,
const char * grantor )
{
DBUG_ENTER ( " ACL_PROXY_USER::store_pk " ) ;
if ( store_pk ( table , host , user , proxied_host , proxied_user ) )
DBUG_ENTER ( " ACL_PROXY_USER::store_pk " ) ;
if ( store_pk ( table , host , user , proxied_host , proxied_user ) )
DBUG_RETURN ( TRUE ) ;
DBUG_PRINT ( " info " , ( " with_grant=%s " , with_grant ? " TRUE " : " FALSE " ) ) ;
if ( table - > field [ MYSQL_PROXY _PRIV_WITH_GRANT ] - > store ( with_grant ? 1 : 0 ,
DBUG_PRINT ( " info " , ( " with_grant=%s " , with_grant ? " TRUE " : " FALSE " ) ) ;
if ( table - > field [ MYSQL_PROXIES _PRIV_WITH_GRANT ] - > store ( with_grant ? 1 : 0 ,
TRUE ) )
DBUG_RETURN ( TRUE ) ;
if ( table - > field [ MYSQL_PROXIES_PRIV_GRANTOR ] - > store ( grantor ,
strlen ( grantor ) ,
system_charset_info ) )
DBUG_RETURN ( TRUE ) ;
DBUG_RETURN ( FALSE ) ;
}
@ -1113,8 +1120,8 @@ my_bool acl_reload(THD *thd)
tables [ 2 ] . init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
C_STRING_WITH_LEN ( " db " ) , " db " , TL_READ ) ;
tables [ 3 ] . init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
C_STRING_WITH_LEN ( " proxy _priv " ) ,
" proxy _priv " , TL_READ ) ;
C_STRING_WITH_LEN ( " proxies _priv " ) ,
" proxies _priv " , TL_READ ) ;
tables [ 0 ] . next_local = tables [ 0 ] . next_global = tables + 1 ;
tables [ 1 ] . next_local = tables [ 1 ] . next_global = tables + 2 ;
tables [ 2 ] . next_local = tables [ 2 ] . next_global = tables + 3 ;
@ -2608,7 +2615,7 @@ acl_insert_proxy_user(ACL_PROXY_USER *new_value)
static int
replace_proxy _priv_table ( THD * thd , TABLE * table , const LEX_USER * user ,
replace_proxies _priv_table ( THD * thd , TABLE * table , const LEX_USER * user ,
const LEX_USER * proxied_user , bool with_grant_arg ,
bool revoke_grant )
{
@ -2616,8 +2623,9 @@ replace_proxy_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
int error ;
uchar user_key [ MAX_KEY_LENGTH ] ;
ACL_PROXY_USER new_grant ;
char grantor [ USER_HOST_BUFF_SIZE ] ;
DBUG_ENTER ( " replace_proxy _priv_table " ) ;
DBUG_ENTER ( " replace_proxies _priv_table " ) ;
if ( ! initialized )
{
@ -2639,6 +2647,8 @@ replace_proxy_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
key_copy ( user_key , table - > record [ 0 ] , table - > key_info ,
table - > key_info - > key_length ) ;
get_grantor ( thd , grantor ) ;
table - > file - > ha_index_init ( 0 , 1 ) ;
if ( table - > file - > index_read_map ( table - > record [ 0 ] , user_key ,
HA_WHOLE_KEY ,
@ -2655,7 +2665,8 @@ replace_proxy_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
ACL_PROXY_USER : : store_data_record ( table , & user - > host , & user - > user ,
& proxied_user - > host ,
& proxied_user - > user ,
with_grant_arg ) ;
with_grant_arg ,
grantor ) ;
}
else
{
@ -2712,7 +2723,7 @@ table_error:
table - > file - > print_error ( error , MYF ( 0 ) ) ; /* purecov: inspected */
abort :
DBUG_PRINT ( " info " , ( " aborting replace_proxy _priv_table " ) ) ;
DBUG_PRINT ( " info " , ( " aborting replace_proxies _priv_table " ) ) ;
table - > file - > ha_index_end ( ) ;
DBUG_RETURN ( - 1 ) ;
}
@ -3962,14 +3973,14 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
proxied_user = str_list + + ;
}
/* open the mysql.user and mysql.db or mysql.proxy _priv tables */
/* open the mysql.user and mysql.db or mysql.proxies _priv tables */
tables [ 0 ] . init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
C_STRING_WITH_LEN ( " user " ) , " user " , TL_WRITE ) ;
if ( is_proxy )
tables [ 1 ] . init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
C_STRING_WITH_LEN ( " proxy _priv " ) ,
" proxy _priv " ,
C_STRING_WITH_LEN ( " proxies _priv " ) ,
" proxies _priv " ,
TL_WRITE ) ;
else
tables [ 1 ] . init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
@ -4063,7 +4074,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
}
else if ( is_proxy )
{
if ( replace_proxy _priv_table ( thd , tables [ 1 ] . table , Str , proxied_user ,
if ( replace_proxies _priv_table ( thd , tables [ 1 ] . table , Str , proxied_user ,
rights & GRANT_ACL ? TRUE : FALSE ,
revoke_grant ) )
result = - 1 ;
@ -5690,8 +5701,8 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
C_STRING_WITH_LEN ( " procs_priv " ) ,
" procs_priv " , TL_WRITE ) ;
( tables + 5 ) - > init_one_table ( C_STRING_WITH_LEN ( " mysql " ) ,
C_STRING_WITH_LEN ( " proxy _priv " ) ,
" proxy _priv " , TL_WRITE ) ;
C_STRING_WITH_LEN ( " proxies _priv " ) ,
" proxies _priv " , TL_WRITE ) ;
tables - > next_local = tables - > next_global = tables + 1 ;
( tables + 1 ) - > next_local = ( tables + 1 ) - > next_global = tables + 2 ;
( tables + 2 ) - > next_local = ( tables + 2 ) - > next_global = tables + 3 ;
@ -6283,7 +6294,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
}
}
/* Handle proxy _priv table. */
/* Handle proxies _priv table. */
if ( ( found = handle_grant_table ( tables , 5 , drop , user_from , user_to ) ) < 0 )
{
/* Handle of table failed, don't touch the in-memory array. */
@ -6291,7 +6302,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
}
else
{
/* Handle proxy _priv array. */
/* Handle proxies _priv array. */
if ( ( handle_grant_struct ( 5 , drop , user_from , user_to ) & & ! result ) | |
found )
result = 1 ; /* At least one record/element found. */