Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26080

SHOW GRANTS does not quote role names properly for DEFAULT ROLE

Details

    Description

      I noticed that MDEV-20076 is fixed already.
      However, this is still minor issue left for SET DEFAULT ROLE

      MariaDB [(none)]> show grants for 'exploit'@'host';
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Grants for exploit@host |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | GRANT `role-exploit` TO `exploit`@`host` |
      | GRANT USAGE ON *.* TO `exploit`@`host` IDENTIFIED BY PASSWORD '*' WITH MAX_STATEMENT_TIME 15.000000 |
      | SET DEFAULT ROLE role-exploit FOR 'exploit'@'host'
      

      If copy-pasted as-is, the last line gets a syntax error.
      Can you update it so when showing grants, all of them are properly quoted?
      SHOW GRANTS does not quote role names properly for DEFAULT ROLE

      Attachments

        Issue Links

          Activity

            anel Anel Husakovic added a comment - - edited

            10.2 is using ' instead of ` so we will proceed with single quotes in 10.2, while in 10.3 (commit fafb35ee517f309d9e507f6e3908caca5d8cd257 used ` and we will use them too in 10.3. I guess serg is ok with that.
            Note that in 10.2 grant <role-x> TO .. in SHOW GRANT is also affected:

            -GRANT test_role TO 'root'@'localhost' WITH ADMIN OPTION
            +GRANT 'test_role' TO 'root'@'localhost' WITH ADMIN OPTION
            -SET DEFAULT ROLE test_role FOR 'root'@'localhost'
            +SET DEFAULT ROLE 'test_role' FOR 'root'@'localhost'
            

            anel Anel Husakovic added a comment - - edited 10.2 is using ' instead of ` so we will proceed with single quotes in 10.2 , while in 10.3 (commit fafb35ee517f309d9e507f6e3908caca5d8cd257 used ` and we will use them too in 10.3 . I guess serg is ok with that. Note that in 10.2 grant <role-x> TO .. in SHOW GRANT is also affected: -GRANT test_role TO 'root'@'localhost' WITH ADMIN OPTION +GRANT 'test_role' TO 'root'@'localhost' WITH ADMIN OPTION -SET DEFAULT ROLE test_role FOR 'root'@'localhost' +SET DEFAULT ROLE 'test_role' FOR 'root'@'localhost'

            Serg can you please review
            10.3+: 4581369e55
            10.2: 63b113e1 (protected branch passes)

            anel Anel Husakovic added a comment - Serg can you please review 10.3+ : 4581369e55 10.2 : 63b113e1 (protected branch passes)

            ok. But add tests with role names including backticks and single quotes. Like

            CREATE ROLE `r``o'l"e`;
            

            this won't be shown correctly in 10.2 (as expected, no need to fix that) but should be shown correctly in 10.3+.

            serg Sergei Golubchik added a comment - ok. But add tests with role names including backticks and single quotes. Like CREATE ROLE `r``o'l"e`; this won't be shown correctly in 10.2 (as expected, no need to fix that) but should be shown correctly in 10.3+.

            Thanks serg. Updated:
            10.2 2495f06a1
            10.3 3fbe30024ff

            anel Anel Husakovic added a comment - Thanks serg . Updated: 10.2 2495f06a1 10.3 3fbe30024ff

            2495f06a1 and 3fbe30024ff are ok to push, thanks!

            serg Sergei Golubchik added a comment - 2495f06a1 and 3fbe30024ff are ok to push, thanks!

            Pushed to 10.2 with d2dddbff4e6f and to 10.3 with 3fbe30024ff0b4e.
            Thanks Serg

            anel Anel Husakovic added a comment - Pushed to 10.2 with d2dddbff4e6f and to 10.3 with 3fbe30024ff0b4e . Thanks Serg

            People

              anel Anel Husakovic
              muhammad.irfan Muhammad Irfan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.