Bug #82636 Issue with 'mysqlreplicate' 1.6.4 utility
Submitted: 18 Aug 2016 12:51 Modified: 14 Dec 2016 23:29
Reporter: Kunal Patil Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.6.4 OS:CentOS
Assigned to: CPU Architecture:Any
Tags: mysqreplicate

[18 Aug 2016 12:51] Kunal Patil
Description:
When I used following command for setting replication 'mysqlreplicate --master=root:admin@<MASTER_IP>:3306 --slave=root:admin@<SLAVE_IP>:3306 --rpl-user=root:admin', observed below issues. (Here note that connection user and replication user is same).

On DB server there is user root@% for connection and replication with all privileges. 

Now, when I executed above command from my client machine (not db machine), it created 'root@<SLAVE_IP>' user on master without granting any permissions to it. After that while giving 'replication slave' permission to this user, in get_grants function in common/user.py file, it selects user using 'select current_user()'. For which it gets 'root@%' as return result. Now, as 'root@%' user has 'ALL Privileges' it just exits with true without granting any permission. 
After that utility sets replication using 'CHANGE MASTER TO ...' query. And after that tries to start slave using 'START SLAVE' query. But while starting replication, slave tries to connect to master using 'root@<SLAVE_IP>' user. Which has got created by mysqlreplicate with no permissions. Because of which it fails with error message 'COM_REGISTER_FAILED'. 

Now, issue here is why new user got created. And if it is getting created then why replication slave is getting executed on current user, rather than getting executed on user which has got created by mysqlreplicate utility. 

How to repeat:
1. One client machine and two DB servers. On both db servers there is user as root@% with all privileges.
2. Execute command "mysqlreplicate --master=root:admin@<MASTER_IP>:3306 --slave=root:admin@<SLAVE_IP>:3306 --rpl-user=root:admin'"
Note : My connection user and replication user both are same and I don't have any requirement of having different replication user. Also security is not a concern for me. So I can have root@% user with all privileges. 

Suggested fix:
In get_grants function in common/user.py file, rather that fetching user from db server using 'select current_user()' query, pass username of created user to this function. And see if this user has required grants or not. And if required permission is not there assign required permission.
[10 Sep 2016 7:39] MySQL Verification Team
Hello Kunal,

Thank you for the report.
Observed this issue with 1.6.4 build.

Thanks,
Umesh
[12 Dec 2016 17:07] Chuck Bell
Posted by developer:
 
Pushed to release-1.6.5
[14 Dec 2016 23:29] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Utilities 1.6.5 release, and here's the changelog entry:

Corrects an issue when using anonymous hosts.

Thank you for the bug report.