Bug #14023 "select ... from mysql.user" produces wrong results in "password" field
Submitted: 14 Oct 2005 9:25 Modified: 18 Oct 2005 16:40
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.15 OS:all Unix
Assigned to: Joerg Bruehe CPU Architecture:Any

[14 Oct 2005 9:25] Joerg Bruehe
Description:
(Attempt of a) release build of 5.0.15, based on ChangeSet
  1.2047 05/10/14 00:03:30 kent@mysql.com +1 -0
  configure.in:
    rc => GA

Tests "grant" and "grant2" fail on _every_ platform, with the symptoms slightly differing from platform to platform. Here are those which seem to be easily readable:

-------------------------------------------------------
*** r/grant.result
--- r/grant.reject
***************
*** 12,18
  grant delete on mysqltest.* to mysqltest_1@localhost;
  select * from mysql.user where user="mysqltest_1";
  Host  User    Password        Select_priv     Insert_priv     Update_priv     Delete_priv     Create_priv     Drop_priv  Reload_priv      Shutdown_priv   Process_priv    File_priv       Grant_priv      References_priv Index_priv      Alter_priv Show_db_priv     Super_priv      Create_tmp_table_priv   Lock_tables_priv        Execute_priv    Repl_slave_priv Repl_client_
priv    Create_view_priv        Show_view_priv  Create_routine_priv     Alter_routine_priv      Create_user_priv        ssl_
type    ssl_cipher      x509_issuer     x509_subject    max_questions   max_updates     max_connections max_user_connections
! localhost     mysqltest_1             N       N       N       N       N       N       N       N       N       N       N  NN       N       N       N       N       N       N       N       N       N       N       N       N       N       SPEC
IFIED   EDH-RSA-DES-CBC3-SHA                    0       0       0       0
  show grants for mysqltest_1@localhost;
  Grants for mysqltest_1@localhost
  GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
--- 12,18
  grant delete on mysqltest.* to mysqltest_1@localhost;
  select * from mysql.user where user="mysqltest_1";
  Host  User    Password        Select_priv     Insert_priv     Update_priv     Delete_priv     Create_priv     Drop_priv  Reload_priv      Shutdown_priv   Process_priv    File_priv       Grant_priv      References_priv Index_priv      Alter_priv Show_db_priv     Super_priv      Create_tmp_table_priv   Lock_tables_priv        Execute_priv    Repl_slave_priv Repl_client_
priv    Create_view_priv        Show_view_priv  Create_routine_priv     Alter_routine_priv      Create_user_priv        ssl_
type    ssl_cipher      x509_issuer     x509_subject    max_questions   max_updates     max_connections max_user_connections
! localhost     mysqltest_1
  show grants for mysqltest_1@localhost;
  Grants for mysqltest_1@localhost
  GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
***************
followed by similar differences. This is the same on all HP-UX boxes.

On other boxes, that output line is lacking several characters (not at the end) or seems to contain several newline characters soon after the user name.

In test "grant2", an (empty ?) password field is written with non-printing characters:
-------------------------------------------------------
*** r/grant2.result
--- r/grant2.reject
***************
*** 122,128
  grant update (c2) on test.t2 to 'mysqltest_2';
  select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
  host  user    password
! %     mysqltest_1
  %     mysqltest_2     *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
  %     mysqltest_3     fffffffffffffffffffffffffffffffffffffffff
  select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
--- 122,128
  grant update (c2) on test.t2 to 'mysqltest_2';
  select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
  host  user    password
! %     mysqltest_1
  %     mysqltest_2     *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
  %     mysqltest_3     fffffffffffffffffffffffffffffffffffffffff
  select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
-------------------------------------------------------
Again, this is output from any HP-UX box. Other machines have similar (or worse) output.

How to repeat:
Test suite failure.
[14 Oct 2005 9:48] Joerg Bruehe
This one seems to be related:

-------------------------------------------------------
*** r/system_mysql_db.result
--- r/system_mysql_db.reject
***************
*** 73,79
  user  CREATE TABLE `user` (
    `Host` char(60) collate utf8_bin NOT NULL default '',
    `User` char(16) collate utf8_bin NOT NULL default '',
!   `Password` char(41) character set latin1 collate latin1_bin NOT NULL default '',
    `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
    `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
    `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
--- 73,79
  user  CREATE TABLE `user` (
    `Host` char(60) collate utf8_bin NOT NULL default '',
    `User` char(16) collate utf8_bin NOT NULL default '',
!   `Password` binary(41) NOT NULL default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
\0',
    `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
    `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
    `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
-------------------------------------------------------
Also happening everywhere.
[14 Oct 2005 11:34] Joerg Bruehe
Found the reason:
In release builds, tests are run using the (new) Perl script "mysql-test-run.pl" 
whereas developers use the (old) Shell script "mysql-test-run".
When the suite is started, the database is initialized with user and privilege tables,
and the two scripts use different means to do that.
[14 Oct 2005 16:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31117
[18 Oct 2005 16:40] Joerg Bruehe
Problem is fixed (for the moment) by changing the command file used by the Perl test suite.
Long-term solution will be to ensure that both the Perl and the shell suite use the same input, preferably together with the input file for Windows, filed as bug#14120.
[18 Oct 2005 16:41] Joerg Bruehe
Forgot to write explicitly: The fix is contained in 5.0.15.