List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:January 7 2008 5:30am
Subject:bk commit into 5.1 tree (tnurnberg:1.2588) BUG#32753
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tnurnberg. When tnurnberg 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@stripped, 2008-01-07 06:30:41+01:00, tnurnberg@stripped +3 -0
  Bug#32753: PAD_CHAR_TO_FULL_LENGTH is not documented and interferes with grant tables
  
  SQL-mode PAD_CHAR_TO_FULL_LENGTH affected mysqld's user-table too. If
  enabled, user-name and host were space-padded and no longer matched
  the login-data of incoming connexions.
  
  Patch disregards pad-flag while loading privileges so ability to log
  in does not depend on SQL-mode.

  mysql-test/r/sql_mode.result@stripped, 2008-01-07 06:30:39+01:00, tnurnberg@stripped +10 -0
    show that SQL-mode 'PAD_CHAR_TO_FULL_LENGTH' does not affect
    loading of privileges (and by extension, ability to log in).

  mysql-test/t/sql_mode.test@stripped, 2008-01-07 06:30:39+01:00, tnurnberg@stripped +29 -0
    show that SQL-mode 'PAD_CHAR_TO_FULL_LENGTH' does not affect
    loading of privileges (and by extension, ability to log in).

  sql/sql_acl.cc@stripped, 2008-01-07 06:30:39+01:00, tnurnberg@stripped +11 -3
    temporarily disable SQL-mode 'PAD_CHAR_TO_FULL_LENGTH' while
    reloading privileges

diff -Nrup a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result
--- a/mysql-test/r/sql_mode.result	2007-06-28 19:34:47 +02:00
+++ b/mysql-test/r/sql_mode.result	2008-01-07 06:30:39 +01:00
@@ -496,3 +496,13 @@ xb	x
 xcx
 drop table t1;
 SET @@SQL_MODE=@OLD_SQL_MODE;
+create user mysqltest_32753@localhost;
+set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
+set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
+flush privileges;
+select current_user();
+current_user()
+mysqltest_32753@localhost
+set session sql_mode=@OLD_SQL_MODE;
+flush privileges;
+drop user mysqltest_32753@localhost;
diff -Nrup a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
--- a/mysql-test/t/sql_mode.test	2007-04-27 00:12:06 +02:00
+++ b/mysql-test/t/sql_mode.test	2008-01-07 06:30:39 +01:00
@@ -279,3 +279,32 @@ select concat('x',b,'x') from t1;
 drop table t1;
 
 SET @@SQL_MODE=@OLD_SQL_MODE;
+
+
+#
+# Bug #32753: PAD_CHAR_TO_FULL_LENGTH is not documented and interferes
+#             with grant tables
+#
+
+create user mysqltest_32753@localhost;
+
+# try to make the user-table space-padded
+--connection default
+set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
+set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
+flush privileges;
+
+# if user-table is affected by PAD_CHAR_TO_FULL_LENGTH, our connect will fail
+# --error 1045
+connect (user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+select current_user();
+
+# clean up
+--connection default
+set session sql_mode=@OLD_SQL_MODE;
+flush privileges;
+
+--disconnect user_32753
+
+--connection default
+drop user mysqltest_32753@localhost;
diff -Nrup a/sql/sql_acl.cc b/sql/sql_acl.cc
--- a/sql/sql_acl.cc	2007-09-27 17:02:19 +02:00
+++ b/sql/sql_acl.cc	2008-01-07 06:30:39 +01:00
@@ -192,7 +192,7 @@ static void update_hostname(acl_host_and
 static bool compare_hostname(const acl_host_and_ip *host,const char *hostname,
 			     const char *ip);
 static my_bool acl_load(THD *thd, TABLE_LIST *tables);
-static my_bool grant_load(TABLE_LIST *tables);
+static my_bool grant_load(THD *thd, TABLE_LIST *tables);
 
 /*
   Convert scrambled password to binary form, according to scramble type, 
@@ -313,8 +313,11 @@ static my_bool acl_load(THD *thd, TABLE_
   bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
   char tmp_name[NAME_LEN+1];
   int password_length;
+  ulong old_sql_mode= thd->variables.sql_mode;
   DBUG_ENTER("acl_load");
 
+  thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
   grant_version++; /* Privileges updated */
 
   acl_cache->clear(1);				// Clear locked hostname cache
@@ -621,6 +624,7 @@ static my_bool acl_load(THD *thd, TABLE_
   return_val=0;
 
 end:
+  thd->variables.sql_mode= old_sql_mode;
   DBUG_RETURN(return_val);
 }
 
@@ -3516,7 +3520,7 @@ my_bool grant_init()
     TRUE  - error
 */
 
-static my_bool grant_load(TABLE_LIST *tables)
+static my_bool grant_load(THD *thd, TABLE_LIST *tables)
 {
   MEM_ROOT *memex_ptr;
   my_bool return_val= 1;
@@ -3524,8 +3528,11 @@ static my_bool grant_load(TABLE_LIST *ta
   bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
   MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
                                                            THR_MALLOC);
+  ulong old_sql_mode= thd->variables.sql_mode;
   DBUG_ENTER("grant_load");
 
+  thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
   (void) hash_init(&column_priv_hash,system_charset_info,
 		   0,0,0, (hash_get_key) get_grant_table,
 		   (hash_free_key) free_grant_table,0);
@@ -3642,6 +3649,7 @@ end_unlock:
   t_table->file->ha_index_end();
   p_table->file->ha_index_end();
   my_pthread_setspecific_ptr(THR_MALLOC, save_mem_root_ptr);
+  thd->variables.sql_mode= old_sql_mode;
   DBUG_RETURN(return_val);
 }
 
@@ -3699,7 +3707,7 @@ my_bool grant_reload(THD *thd)
   old_func_priv_hash= func_priv_hash;
   old_mem= memex;
 
-  if ((return_val= grant_load(tables)))
+  if ((return_val= grant_load(thd, tables)))
   {						// Error. Revert to old hash
     DBUG_PRINT("error",("Reverting to old privileges"));
     grant_free();				/* purecov: deadcode */
Thread
bk commit into 5.1 tree (tnurnberg:1.2588) BUG#32753Tatjana A Nuernberg7 Jan