Bug #72390 Workbench-Enterprise Backup integration doesn't parse Grant table robustly
Submitted: 18 Apr 2014 21:27 Modified: 4 Nov 2014 4:42
Reporter: Ravi Gadhia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:Commercial Workbench 6.1.4 OS:Windows (Windows 7 Professional)
Assigned to: Juan Rene Ramirez Monarrez CPU Architecture:Any

[18 Apr 2014 21:27] Ravi Gadhia
Description:
I think I found the problem with Backup on Workbench.  When clicking on “Online Backup” or “Backup Recovery” in Workbench, it executes some Python code that connects to the MySQL instance and parses through the Grants table for user ‘mysqlbackup@localhost’.  

On my box it looks like this:

mysql> show grants for mysqlbackup@localhost;
+------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mysqlbackup@localhost                                                                                                               |
+------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT RELOAD, SUPER, REPLICATION CLIENT ON *.* TO 'mysqlbackup'@'localhost' IDENTIFIED BY PASSWORD '*1119B3038289B6F92FD8FE1E50E2F2FDEFE822CF' |
| GRANT CREATE TEMPORARY TABLES ON `mysql`.* TO 'mysqlbackup'@'localhost'                                                                        |
| GRANT INSERT, UPDATE, CREATE, DROP ON `mysql.backup\_progress`.* TO 'mysqlbackup'@'localhost'                                                  |
| GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `mysql.backup\_history`.* TO 'mysqlbackup'@'localhost'                                           |
| GRANT INSERT, CREATE, DROP ON `mysql`.`ibbackup_binlog_marker` TO 'mysqlbackup'@'localhost'                                                    |
| GRANT SELECT, INSERT, CREATE, DROP ON `mysql`.`backup_history` TO 'mysqlbackup'@'localhost'                                                    |
| GRANT INSERT, CREATE, DROP ON `mysql`.`backup_progress` TO 'mysqlbackup'@'localhost'                                                           |
+------------------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set (0.00 sec)

The python code that parses it is (take from C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wb_admin_user_privileges.py):
    def set_from_string(self, data):
        log_warning('RAVI2 self = %s data = %s\n' % (self, data))
        if data != '*' and data != '*.*':
          if data.find('.') == -1:
              self.object = data
          else:
              self.schema, self.object = data.rsplit('.',1)
              #self.schema, self.object = data.split('.')

The last line which is commented out above generates an exception when parsing this GRANT line:
| GRANT INSERT, UPDATE, CREATE, DROP ON `mysql.backup\_progress`.* TO 'mysqlbackup'@'localhost'                                                  |

This shows up in Logfile as:

13:41:46 [WRN][wb_admin_user_privileges.py:set_from_string:24]: RAVI2 self = <wb_admin_user_privileges.PrivilegeTarget object at 0x09E75590> data = mysql.backup_progress.*
13:41:46 [ERR][wb_admin_main.py:tab_changed:190]: Unhandled exception in Admin for <wba_meb.wb_admin_meb.WbAdminEnterpriseBackup; proxy of <Swig Object of type 'mforms::Box *' at 0x090DC470> >: Traceback (most recent call last):
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wb_admin_main.py", line 187, in tab_changed
    panel.page_activated()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb.py", line 219, in page_activated
    self.create_ui()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb.py", line 92, in create_ui
    self.context.init_config()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb_common.py", line 136, in init_config
    self.config.validate()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\workbench\change_tracker.py", line 329, in __call__
    ret_val = self.func(*args)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb_common.py", line 1171, in validate
    self.validate_backup_account()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\workbench\change_tracker.py", line 329, in __call__
    ret_val = self.func(*args)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb_common.py", line 1150, in validate_backup_account
    ret_val, error = self._validate_privileges(user)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\workbench\change_tracker.py", line 329, in __call__
    ret_val = self.func(*args)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wba_meb\wb_admin_meb_common.py", line 1040, in _validate_privileges
    grant_verifier.load_privileges(target_host)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wb_admin_user_privileges.py", line 243, in load_privileges
    target.set_from_string(target_string)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1\modules\wb_admin_user_privileges.py", line 29, in set_from_string
    self.schema, self.object = data.rsplit('.',2)
ValueError: too many values to unpack

My Fix seems to work, but I’m not sure if it will compromise functionality.   

              self.schema, self.object = data.rsplit('.',1)

How to repeat:
1.  Set Grants Table as in above descripton.

2.  Start Workbench 6.1.4

3.  Click on Enterprise Backup

4.  Show Logs
[9 Sep 2014 15:22] Juan Rene Ramirez Monarrez
There were several issue with the parsing of the grant statement, all of them were fixed and a proper parsing logic was implemented for the schema/table parsing.

Thanks for submitting the bug report!

Fix will be available on the next 6.2 version.
[9 Sep 2014 18:59] Juan Rene Ramirez Monarrez
Posted by developer:
 
Several issues were identified on the grant parsing logic, logic has been improved.

Fix will be available on the next release.

Thanks for submitting the bug!
[4 Nov 2014 4:42] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Workbench 6.2.3 release, and here's the changelog entry:

Several issues were identified and fixed in the GRANT parsing logic for
MYSQL Enterprise Backup. Related unhandled exceptions are no longer generated.

Thank you for the bug report.