List:Commits« Previous MessageNext Message »
From:msvensson Date:December 28 2005 8:23am
Subject:bk commit into 4.1 tree (msvensson:1.2462) BUG#15775
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2462 05/12/28 09:23:27 msvensson@neptunus.(none) +3 -0
  BUG#15775 "drop user" command does not refresh acl_check_hosts
     - DROP USER command didn't reload the acl_check_hosts cache causing subsequent 
       connect's via TCP to fail randomly.
     - 4.1 version

  sql/sql_acl.cc
    1.171 05/12/28 09:23:21 msvensson@neptunus.(none) +12 -4
    Reload acl_check_hosts as its memory is mapped to acl_user
    Use acl_user->host.hostname when searching the acl_check_hosts list

  mysql-test/t/grant2.test
    1.15 05/12/28 09:23:21 msvensson@neptunus.(none) +33 -0
    Add test for to check that connect via TCP work after "drop user"

  mysql-test/r/grant2.result
    1.14 05/12/28 09:23:21 msvensson@neptunus.(none) +12 -0
    Update test results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug15775_part2/my41-bug15775_part2

--- 1.170/sql/sql_acl.cc	2005-11-14 13:33:52 +01:00
+++ 1.171/sql/sql_acl.cc	2005-12-28 09:23:21 +01:00
@@ -1151,7 +1151,7 @@
 	if (j == acl_wild_hosts.elements)	// If new
 	  (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)))
       {
 	if (my_hash_insert(&acl_check_hosts,(byte*) acl_user))
@@ -3719,17 +3719,25 @@
 						     record[0])))
       {
 	tables[0].table->file->print_error(error, MYF(0));
-	DBUG_RETURN(-1);
+	result= -1;
+	goto end;
       }
       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));
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
-  if (result)
-    my_error(ER_DROP_USER, MYF(0));
   DBUG_RETURN(result);
 }
 

--- 1.13/mysql-test/r/grant2.result	2005-09-01 15:01:22 +02:00
+++ 1.14/mysql-test/r/grant2.result	2005-12-28 09:23:21 +01:00
@@ -131,3 +131,15 @@
  revoke all on *.* from 'mysqltest_1'@'localhost';
 unlock tables;
 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;

--- 1.14/mysql-test/t/grant2.test	2005-09-01 15:01:22 +02:00
+++ 1.15/mysql-test/t/grant2.test	2005-12-28 09:23:21 +01:00
@@ -206,4 +206,37 @@
 disconnect con2root;
 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
Thread
bk commit into 4.1 tree (msvensson:1.2462) BUG#15775msvensson28 Dec