Commit ID
|
Contributor: | gopal.s...@oracle.com | Files Modified: | 3 |
| Date: | 28-March-2012 at 14:50 | Lines Added: | 221 | |
| Repository: | lp:mysql-server | Lines Removed: | 218 | |
| Commit Comment: | 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. |
|||
| Language | Code Added | Code Removed | Comments Added | Comment Removed | Blanks Added | Blanks Removed | |
|---|---|---|---|---|---|---|---|
| C++ | 199 | 209 | 19 | 9 | 3 | 0 | |
| File | Language | Code Added | Code Removed | Comments Added | Comment Removed | Blanks Added | Blanks Removed | |
|---|---|---|---|---|---|---|---|---|
| mysql-test/r/grant.result | No source code was detected in this file. | |||||||
| mysql-test/t/grant.test | No source code was detected in this file. | |||||||
| sql/sql_acl.cc | C++ | 199 | 209 | 19 | 9 | 3 | 0 | |
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.