LP #844034: pt-show-grants --separate fails with proxy user

Description

**Reported in Launchpad by Derek Downey last update 19-06-2012 19:59:13

System info: Using pt-show-grants version 1.0.1 on mysql 5.5.15

pt-show-grants gives the following error when the --separate flag is specified: Use of uninitialized value in split at /usr/bin/pt-show-grants line 1714.

Here is output without separate flag:

$ pt-show-grants
– Grants dumped by pt-show-grants
– Dumped from server rs.dev via TCP/IP, MySQL 5.5.15-log at 2011-09-07 10:55:09
– Grants for 'dtest'@'localhost'
GRANT ALL PRIVILEGES ON . TO 'dtest'@'localhost' IDENTIFIED BY PASSWORD 'mypass';
– Grants for 'proxy'@'localhost'
GRANT PROXY ON 'dtest'@'localhost' TO 'proxy'@'localhost';
GRANT USAGE ON . TO 'proxy'@'localhost';
– Grants for 'root'@'localhost'
GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY PASSWORD 'rootPass' WITH GRANT OPTION;
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION;

And output with separate flag:
$ pt-show-grants --separate
– Grants dumped by pt-show-grants
– Dumped from server rs.dev via TCP/IP, MySQL 5.5.15-log at 2011-09-07 10:55:01
– Grants for 'dtest'@'localhost'
GRANT ALL PRIVILEGES ON . TO 'dtest'@'localhost' IDENTIFIED BY PASSWORD 'mypass';
Use of uninitialized value in split at /usr/bin/pt-show-grants line 1714.

I am only assuming this is because there is no GRANT USAGE clause for the user `dtest`@`localhost`, which is set up as a proxy user.

Environment

None

Smart Checklist

Activity

lpjirasync January 24, 2018 at 2:52 PM

**Comment from Launchpad by: Baron Schwartz on: 12-06-2012 00:20:39

This bug will be fixed in the upcoming release.

lpjirasync January 24, 2018 at 2:52 PM

**Comment from Launchpad by: William Taylor on: 03-04-2012 18:49:15

Thanks Barron. In hindsight I probably should have submitted this as a separate bug. Here is an updated patch.
My original patch only fixed running with --revoke this fixes running with --separate also.

If u have a GRANT PROXY option --revoke and or --separate will fail because the regex pt-show-grants uses only tests for backticks or asterisk after the ON statement but PROXY GRANTS use single quotes.

example:
asterisk: GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1' WITH GRANT OPTION;
backticks: GRANT ALL PRIVILEGES ON `test`.* TO 'root'@'127.0.0.1';

This is the GRANT statement that breaks pt-show-grants using --revoke and or --separate because it uses single quotes
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION;

with --revoke
Use of uninitialized value $grants in concatenation (.) or string at /usr/bin/pt-show-grants line 1767.
with --separate
Use of uninitialized value $grants in split at /usr/bin/pt-show-grants line 1718.

Thanks,
William

lpjirasync January 24, 2018 at 2:52 PM

**Comment from Launchpad by: Baron Schwartz on: 03-04-2012 17:42:18

We are about to release 2.1.1 and this bug will not be fixed due to lack of time. But we can target it to the next releases in the 2.0 and 2.1 series, and if you can provide a complete fix including updated test cases and any new test cases needed, that will greatly ease the amount of work we will need to do ourselves. Even a "simple" 616-byte patch is a lot more work than meets the eye.

lpjirasync January 24, 2018 at 2:52 PM

**Comment from Launchpad by: William Taylor on: 03-04-2012 17:20:27

Can we get this patch applied? Just had to re-apply patch after an upgrade happened last month. Took me a bit to remember why revoke wasn't working and to notice the upgrade happened.

lpjirasync January 24, 2018 at 2:52 PM

**Comment from Launchpad by: William Taylor on: 05-03-2012 19:08:05

I ran into this bug with the --revoke option.
I believe this patch will fix the problem

Done

Details

Assignee

Reporter

Priority

Smart Checklist

Created January 24, 2018 at 2:51 PM
Updated January 24, 2018 at 2:52 PM
Resolved January 24, 2018 at 2:52 PM