Commit 6de95199 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1

into  neptunus.(none):/home/msvensson/mysql/bug15775_part2/my41-bug15775_part2
parents 535b23be 2fb6cb5a
...@@ -131,3 +131,15 @@ lock table mysql.user write; ...@@ -131,3 +131,15 @@ lock table mysql.user write;
revoke all on *.* from 'mysqltest_1'@'localhost'; revoke all on *.* from 'mysqltest_1'@'localhost';
unlock tables; unlock tables;
drop user 'mysqltest_1'@'localhost'; drop user 'mysqltest_1'@'localhost';
insert into mysql.user (user, host) values
('mysqltest_1', 'host1'),
('mysqltest_2', 'host2'),
('mysqltest_3', 'host3'),
('mysqltest_4', 'host4'),
('mysqltest_5', 'host5'),
('mysqltest_6', 'host6'),
('mysqltest_7', 'host7');
flush privileges;
drop user mysqltest_3@host3;
drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,
mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;
...@@ -206,4 +206,37 @@ drop user 'mysqltest_1'@'localhost'; ...@@ -206,4 +206,37 @@ drop user 'mysqltest_1'@'localhost';
disconnect con2root; disconnect con2root;
disconnect con3root; disconnect con3root;
#
# Bug #15775: "drop user" command does not refresh acl_check_hosts
#
# Create some test users
insert into mysql.user (user, host) values
('mysqltest_1', 'host1'),
('mysqltest_2', 'host2'),
('mysqltest_3', 'host3'),
('mysqltest_4', 'host4'),
('mysqltest_5', 'host5'),
('mysqltest_6', 'host6'),
('mysqltest_7', 'host7');
flush privileges;
# Drop one user
drop user mysqltest_3@host3;
# This connect failed before fix since the acl_check_hosts list was corrupted by the "drop user"
connect (con8,127.0.0.1,root,,test,$MASTER_MYPORT,);
disconnect con8;
connection default;
# Clean up - Drop all of the remaining users at once
drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,
mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;
# Check that it's still possible to connect
connect (con9,127.0.0.1,root,,test,$MASTER_MYPORT,);
disconnect con9;
connection default;
# End of 4.1 tests # End of 4.1 tests
...@@ -1151,7 +1151,7 @@ static void init_check_host(void) ...@@ -1151,7 +1151,7 @@ static void init_check_host(void)
if (j == acl_wild_hosts.elements) // If new if (j == acl_wild_hosts.elements) // If new
(void) push_dynamic(&acl_wild_hosts,(char*) &acl_user->host); (void) push_dynamic(&acl_wild_hosts,(char*) &acl_user->host);
} }
else if (!hash_search(&acl_check_hosts,(byte*) &acl_user->host, else if (!hash_search(&acl_check_hosts,(byte*) acl_user->host.hostname,
(uint) strlen(acl_user->host.hostname))) (uint) strlen(acl_user->host.hostname)))
{ {
if (my_hash_insert(&acl_check_hosts,(byte*) acl_user)) if (my_hash_insert(&acl_check_hosts,(byte*) acl_user))
...@@ -3719,17 +3719,25 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) ...@@ -3719,17 +3719,25 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
record[0]))) record[0])))
{ {
tables[0].table->file->print_error(error, MYF(0)); tables[0].table->file->print_error(error, MYF(0));
DBUG_RETURN(-1); result= -1;
goto end;
} }
delete_dynamic_element(&acl_users, acl_userd); delete_dynamic_element(&acl_users, acl_userd);
} }
} }
if (result)
my_error(ER_DROP_USER, MYF(0));
end:
/* Reload acl_check_hosts as its memory is mapped to acl_user */
delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts);
init_check_host();
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
close_thread_tables(thd); close_thread_tables(thd);
if (result)
my_error(ER_DROP_USER, MYF(0));
DBUG_RETURN(result); DBUG_RETURN(result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment