[MDEV-5999] MySQL Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY - REQUIRES FLUSH PRIVILEGES Created: 2014-04-01  Updated: 2017-02-27  Resolved: 2017-02-27

Status: Closed
Project: MariaDB Server
Component/s: Authentication and Privilege System
Affects Version/s: 10.0.10
Fix Version/s: 5.5.55, 10.0.30, 10.1.22, 10.2.5

Type: Bug Priority: Major
Reporter: Sergey Vojtovich Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-4784 merge test cases from 5.6 Stalled
Sprint: 10.0.29, 10.0.30

 Description   

revno: 3690.1.180
committer: gopal.shankar@oracle.com
branch nick: mysql-flushpriv2
timestamp: Thu 2012-03-29 00:20:54 +0530
message:
  Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY -
                        REQUIRES FLUSH PRIVILEGES
 
  PROBLEM:
    RENAME USER does not work as expected when from_user contains just
  IP and to_user contains IP/MASK. Attempt to connect to MySQL using
  renamed user fails. Attempts to connect succeed only after command
  FLUSH PRIVILEGES.
 
  ANALYSIS:
    MySQL maintains access control list for users in global DYNAMIC ARRAY
  'acl_users'. This list is updated by acl_reload(), which loads 'acl_users'
  from mysql.user table.
 
    For faster search we maintain HASH acl_check_hosts, which contains
  user details with hostnames without any wild cards. All the users whose
  host name contains wild cards are stored in DYNAMIC_ARRAY acl_wild_hosts.
 
    ADD/DROP/RENAME user basically updates 'acl_users' along with mysql.user.
  At the end of these operations init_check_hosts() is called to update
  acl_check_hosts and  acl_wild_cards based on 'acl_users'.
 
  Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY -
                        REQUIRES FLUSH PRIVILEGES
 
  PROBLEM:
    RENAME USER does not work as expected when from_user contains just
  IP and to_user contains IP/MASK. Attempt to connect to MySQL using
  renamed user fails. Attempts to connect succeed only after command
  FLUSH PRIVILEGES.
 
  ANALYSIS:
    MySQL maintains access control list for users in global DYNAMIC ARRAY
  'acl_users'. This list is updated by acl_reload(), which loads 'acl_users'
  from mysql.user table.
 
    For faster search we maintain HASH acl_check_hosts, which contains
  user details with hostnames without any wild cards. All the users whose
  host name contains wild cards are stored in DYNAMIC_ARRAY acl_wild_hosts.
 
    ADD/DROP/RENAME user basically updates 'acl_users' along with mysql.user.
  At the end of these operations init_check_hosts() is called to update
  acl_check_hosts and  acl_wild_cards based on 'acl_users'.
 
    During RENAME, when it updates 'acl_users' in handle_grant_struct(),
  hostname is copied into 'acl_users' list updating only ACL_USER->hostname
  but it does not update ACL_USER->host->ip, ACL_USER->host->ip_mask. This
  is route cause for this bug.
 
    FLUSH PRIVILEGES command invokes acl_reload(). This function updates all
  members of ACL_USER->host (including ip and ip_mask). Hence attempts to connect
  to MySQL succeeds there after.
 
  FIX:
    Make changes to handle_grant_struct() to properly update ACL_USER->host->ip,
  ACL_USER->host->ip_mask. This is done using existing update_hostname().
 
  Note:
    In addition to the fix described above, the code related to acl_host_and_ip is
  modified. The new code helps avoid doing similar mistakes, of updating
  hostname, without updating ip_mask. These changes also improves the related code.



 Comments   
Comment by Oleksandr Byelkin [ 2016-06-20 ]

mysql-server git revision id is 0abdeed1d6dd697cc337b9767b1d6a1500f4028d

Comment by Oleksandr Byelkin [ 2016-06-20 ]

if CREATE USER works without FLUSH PROVILAGES so RENAME also should work

Comment by Oleksandr Byelkin [ 2017-01-10 ]

revision-id: 2c36ba67240850d909bf75fc36346261f37019fb (mariadb-10.0.28-43-g2c36ba67240)
parent(s): eed319b6fb543849046c8009c38575455e173dc2
committer: Oleksandr Byelkin
timestamp: 2017-01-10 16:02:42 +0100
message:

MySQL Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY - REQUIRES FLUSH PRIVILEGES

Port & fix of MySQL patch for the problem.

Generated at Thu Feb 08 07:08:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.