List:Commits« Previous MessageNext Message »
From:gluh Date:January 31 2006 11:11am
Subject:bk commit into 5.0 tree (gluh:1.2018) BUG#14385
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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.2018 06/01/31 15:11:08 gluh@stripped +3 -0
  Fix for bug#14385 GRANT and mapping to correct user account problems
    Check if the host of table hash record exactly matches host from GRANT command

  sql/sql_acl.cc
    1.187 06/01/31 15:11:02 gluh@stripped +17 -12
    Fix for bug#14385 GRANT and mapping to correct user account problems
      Check if the host of table hash record exactly matches host from GRANT command

  mysql-test/t/grant.test
    1.39 06/01/31 15:11:02 gluh@stripped +15 -0
    Fix for bug#14385 GRANT and mapping to correct user account problems
      test case

  mysql-test/r/grant.result
    1.49 06/01/31 15:11:02 gluh@stripped +16 -0
    Fix for bug#14385 GRANT and mapping to correct user account problems
      test case

# 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:	gluh
# Host:	eagle.intranet.mysql.r18.ru
# Root:	/home/gluh/MySQL/Bugs/5.0.14385

--- 1.186/sql/sql_acl.cc	Wed Jan 18 20:09:18 2006
+++ 1.187/sql/sql_acl.cc	Tue Jan 31 15:11:02 2006
@@ -76,7 +76,7 @@ static bool update_user_table(THD *thd, 
 			      const char *new_password, uint new_password_len);
 static void update_hostname(acl_host_and_ip *host, const char *hostname);
 static bool compare_hostname(const acl_host_and_ip *host,const char *hostname,
-			     const char *ip);
+			     const char *ip, bool exact);
 static my_bool acl_load(THD *thd, TABLE_LIST *tables);
 static my_bool grant_load(TABLE_LIST *tables);
 
@@ -750,7 +750,7 @@ int acl_getroot(THD *thd, USER_RESOURCES
     ACL_USER *acl_user_tmp= dynamic_element(&acl_users,i,ACL_USER*);
     if (!acl_user_tmp->user || !strcmp(sctx->user, acl_user_tmp->user))
     {
-      if (compare_hostname(&acl_user_tmp->host, sctx->host, sctx->ip))
+      if (compare_hostname(&acl_user_tmp->host, sctx->host, sctx->ip, 0))
       {
         /* check password: it should be empty or valid */
         if (passwd_len == acl_user_tmp->salt_len)
@@ -970,7 +970,7 @@ bool acl_getroot_no_password(Security_co
     if ((!acl_user->user && !user[0]) ||
 	(acl_user->user && strcmp(user, acl_user->user) == 0))
     {
-      if (compare_hostname(&acl_user->host, host, ip))
+      if (compare_hostname(&acl_user->host, host, ip, 0))
       {
 	res= 0;
 	break;
@@ -986,7 +986,7 @@ bool acl_getroot_no_password(Security_co
       if (!acl_db->user ||
 	  (user && user[0] && !strcmp(user, acl_db->user)))
       {
-	if (compare_hostname(&acl_db->host, host, ip))
+	if (compare_hostname(&acl_db->host, host, ip, 0))
 	{
 	  if (!acl_db->db || (db && !wild_compare(db, acl_db->db, 0)))
 	  {
@@ -1200,7 +1200,7 @@ ulong acl_get(const char *host, const ch
     ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*);
     if (!acl_db->user || !strcmp(user,acl_db->user))
     {
-      if (compare_hostname(&acl_db->host,host,ip))
+      if (compare_hostname(&acl_db->host,host,ip,0))
       {
 	if (!acl_db->db || !wild_compare(db,acl_db->db,db_is_pattern))
 	{
@@ -1222,7 +1222,7 @@ ulong acl_get(const char *host, const ch
   for (i=0 ; i < acl_hosts.elements ; i++)
   {
     ACL_HOST *acl_host=dynamic_element(&acl_hosts,i,ACL_HOST*);
-    if (compare_hostname(&acl_host->host,host,ip))
+    if (compare_hostname(&acl_host->host, host, ip, 0))
     {
       if (!acl_host->db || !wild_compare(db,acl_host->db,db_is_pattern))
       {
@@ -1332,7 +1332,7 @@ bool acl_check_host(const char *host, co
   for (uint i=0 ; i < acl_wild_hosts.elements ; i++)
   {
     acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,i,acl_host_and_ip*);
-    if (compare_hostname(acl, host, ip))
+    if (compare_hostname(acl, host, ip, 0))
     {
       VOID(pthread_mutex_unlock(&acl_cache->lock));
       return 0;					// Host ok
@@ -1545,7 +1545,7 @@ find_acl_user(const char *host, const ch
       if (exact ? !my_strcasecmp(&my_charset_latin1, host,
                                  acl_user->host.hostname ?
 				 acl_user->host.hostname : "") :
-          compare_hostname(&acl_user->host,host,host))
+          compare_hostname(&acl_user->host, host, host, 0))
       {
 	DBUG_RETURN(acl_user);
       }
@@ -1599,13 +1599,18 @@ static void update_hostname(acl_host_and
 
 
 static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
-			     const char *ip)
+			     const char *ip, bool exact)
 {
   long tmp;
   if (host->ip_mask && ip && calc_ip(ip,&tmp,'\0'))
   {
     return (tmp & host->ip_mask) == host->ip;
   }
+  if (exact)
+    return (!host->hostname || 
+            (hostname && !my_strcasecmp(system_charset_info, hostname, 
+                                        host->hostname)) ||
+            (ip && !strcmp(ip, host->hostname)));
   return (!host->hostname ||
 	  (hostname && !wild_case_compare(system_charset_info,
                                           hostname,host->hostname)) ||
@@ -2256,12 +2261,12 @@ static GRANT_NAME *name_hash_search(HASH
   {
     if (exact)
     {
-      if (compare_hostname(&grant_name->host, host, ip))
+      if (compare_hostname(&grant_name->host, host, ip, exact))
 	return grant_name;
     }
     else
     {
-      if (compare_hostname(&grant_name->host, host, ip) &&
+      if (compare_hostname(&grant_name->host, host, ip, 0) &&
           (!found || found->sort < grant_name->sort))
 	found=grant_name;					// Host ok
     }
@@ -3834,7 +3839,7 @@ bool check_grant_db(THD *thd,const char 
 							  idx);
     if (len < grant_table->key_length &&
 	!memcmp(grant_table->hash_key,helping,len) &&
-        compare_hostname(&grant_table->host, sctx->host, sctx->ip))
+        compare_hostname(&grant_table->host, sctx->host, sctx->ip, 0))
     {
       error=0;					// Found match
       break;

--- 1.48/mysql-test/r/grant.result	Mon Jan  9 20:12:14 2006
+++ 1.49/mysql-test/r/grant.result	Tue Jan 31 15:11:02 2006
@@ -624,3 +624,19 @@ drop user mysqltest_7@;
 flush privileges;
 show grants for mysqltest_7@;
 ERROR 42000: There is no such grant defined for user 'mysqltest_7' on host ''
+create database mysqltest;
+use mysqltest;
+create table t1(f1 int);
+GRANT DELETE ON mysqltest.t1 TO mysqltest1@'%';
+GRANT SELECT ON mysqltest.t1 TO mysqltest1@'192.%';
+show grants for mysqltest1@'192.%';
+Grants for mysqltest1@192.%
+GRANT USAGE ON *.* TO 'mysqltest1'@'192.%'
+GRANT SELECT ON `mysqltest`.`t1` TO 'mysqltest1'@'192.%'
+show grants for mysqltest1@'%';
+Grants for mysqltest1@%
+GRANT USAGE ON *.* TO 'mysqltest1'@'%'
+GRANT DELETE ON `mysqltest`.`t1` TO 'mysqltest1'@'%'
+drop user mysqltest1@'192.%';
+drop user mysqltest1@'%';
+drop database mysqltest;

--- 1.38/mysql-test/t/grant.test	Mon Jan  9 20:12:14 2006
+++ 1.39/mysql-test/t/grant.test	Tue Jan 31 15:11:02 2006
@@ -512,3 +512,18 @@ flush privileges; # BUG#16297(flush shou
 show grants for mysqltest_7@;
 
 # End of 4.1 tests
+
+
+#
+# Bug#14385: GRANT and mapping to correct user account problems
+#
+create database mysqltest;
+use mysqltest;
+create table t1(f1 int);
+GRANT DELETE ON mysqltest.t1 TO mysqltest1@'%';
+GRANT SELECT ON mysqltest.t1 TO mysqltest1@'192.%';
+show grants for mysqltest1@'192.%';
+show grants for mysqltest1@'%';
+drop user mysqltest1@'192.%';
+drop user mysqltest1@'%';
+drop database mysqltest;
Thread
bk commit into 5.0 tree (gluh:1.2018) BUG#14385gluh31 Jan