Bug #37781 mysql_drop_user calls get_current_user() twice for no reason
Submitted: 1 Jul 2008 17:35 Modified: 12 Aug 2008 17:40
Reporter: Mark Callaghan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.62, 5.0, 5.1, 6.0 bzr OS:Any
Assigned to: Kristofer Pettersson CPU Architecture:Any
Tags: get_current_user, mysql_drop_user

[1 Jul 2008 17:35] Mark Callaghan
Description:
Two calls to get_current_user is harmless, but shouldn't be there.

bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
  int result;
  String wrong_users;
  LEX_USER *user_name, *tmp_user_name;
  List_iterator <LEX_USER> user_list(list);
  TABLE_LIST tables[GRANT_TABLES];
  DBUG_ENTER("mysql_drop_user");

  /* DROP USER may be skipped on replication client. */
  if ((result= open_grant_tables(thd, tables)))
    DBUG_RETURN(result != 1);

  rw_wrlock(&LOCK_grant);
  VOID(pthread_mutex_lock(&acl_cache->lock));

  while ((tmp_user_name= user_list++))
  {
    user_name= get_current_user(thd, tmp_user_name);         <---- call 1
    if (!(user_name= get_current_user(thd, tmp_user_name)))  <---- call 2

How to repeat:
Read the code in sql_acl.cc

Suggested fix:
Remove the first call
[1 Jul 2008 17:53] Sveta Smirnova
Thank you for the report.

Verified as described.
[29 Jul 2008 13:33] 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/commits/50648

2650 Kristofer Pettersson	2008-07-29
      Bug#37781 mysql_drop_user calls get_current_user() twice for no reason
      
      Fixed typo and removed duplicate call to get_current_user.
[12 Aug 2008 14:43] Bugs System
Pushed into 6.0.7-alpha  (revid:kpettersson@mysql.com-20080729133709-j5gignlxtuzw3fqr) (version source revid:davi.arnaut@sun.com-20080812141852-8e6knbqclpfd8irn) (pib:3)
[12 Aug 2008 15:12] Bugs System
Pushed into 5.1.28  (revid:kpettersson@mysql.com-20080729133709-j5gignlxtuzw3fqr) (version source revid:davi.arnaut@sun.com-20080812142843-he05ncsggstbn57z) (pib:3)
[12 Aug 2008 17:40] Paul DuBois
No user-visible change. No changelog entry needed.
[12 Aug 2008 18:51] 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/commits/51449

2647 Davi Arnaut	2008-08-12 [merge]
      Merge mysql-5.0-bugteam into mysql-5.0
[12 Aug 2008 19:12] Bugs System
Pushed into 5.0.68  (revid:kpettersson@mysql.com-20080729133709-j5gignlxtuzw3fqr) (version source revid:davi.arnaut@sun.com-20080812185100-d47qb8mz2ye6pe6b) (pib:3)
[28 Aug 2008 20:16] Bugs System
Pushed into 6.0.7-alpha  (revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (version source revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (pib:3)
[14 Sep 2008 3:54] Bugs System
Pushed into 6.0.7-alpha  (revid:kpettersson@mysql.com-20080729133709-j5gignlxtuzw3fqr) (version source revid:v.narayanan@sun.com-20080820070709-nx09bk6qx81osd5s) (pib:3)