diff --git a/go/vt/vttablet/tabletmanager/rpc_vreplication.go b/go/vt/vttablet/tabletmanager/rpc_vreplication.go index 73d1dbf049a..64f0d5bf2ae 100644 --- a/go/vt/vttablet/tabletmanager/rpc_vreplication.go +++ b/go/vt/vttablet/tabletmanager/rpc_vreplication.go @@ -62,20 +62,22 @@ const ( // Check if workflow is still copying. sqlGetVReplicationCopyStatus = "select distinct vrepl_id from %s.copy_state where vrepl_id = %d" // Validate the minimum set of permissions needed to manage vreplication metadata. + // This is a simple check for a matching user rather than any specific user@host + // combination. sqlValidateVReplicationPermissions = ` select if(count(*)>0, 1, 0) as good from mysql.user as u left join mysql.db as d on (u.user = d.user) left join mysql.tables_priv as t on (u.user = t.user) where u.user = %a and ( - (u.insert_priv = 'y' and u.update_priv = 'y' and u.delete_priv = 'y') - or (d.db = %a and u.insert_priv = 'y' and u.update_priv = 'y' and u.delete_priv = 'y') - or (t.db = %a and t.table_name = 'vreplication' + (u.insert_priv = 'y' and u.update_priv = 'y' and u.delete_priv = 'y') /* user has global privs */ + or (d.db = %a and u.insert_priv = 'y' and u.update_priv = 'y' and u.delete_priv = 'y') /* user has db privs */ + or (t.db = %a and t.table_name = 'vreplication' /* user has table privs */ and find_in_set('insert', t.table_priv) and find_in_set('update', t.table_priv) and find_in_set('delete', t.table_priv) ) - ) + ) limit 1 ` )