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

Wrong user in SET DEFAULT ROLE error

Details

    Description

      The error message for SET DEFAULT ROLE refers to the user performing the operation instead of the target user. This is misleading as the user giving the grant doesn't require the grant itself, only the target user.

      Here's an example (and a test case) that reproduces the problem:

      MariaDB [test]> create role test_role;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> create user test_user;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> set default role test_role for test_user;
      ERROR 1959 (OP000): User `maxuser`@`127.0.0.1` has not been granted role `test_role`
      MariaDB [test]> grant test_role to maxuser@127.0.0.1;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> set default role test_role for test_user;
      ERROR 1959 (OP000): User `maxuser`@`127.0.0.1` has not been granted role `test_role`
      MariaDB [test]> grant test_role to test_user;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> set default role test_role for test_user;
      Query OK, 0 rows affected (0.000 sec)
      

      Attachments

        Issue Links

          Activity

            markus makela markus makela created issue -
            markus makela markus makela made changes -
            Field Original Value New Value
            serg Sergei Golubchik made changes -
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            serg Sergei Golubchik made changes -
            Assignee Anel Husakovic [ anel ]
            anel Anel Husakovic made changes -
            anel Anel Husakovic made changes -
            anel Anel Husakovic made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status Confirmed [ 10101 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 126462 ] MariaDB v4 [ 143805 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            danblack Daniel Black made changes -
            Status Stalled [ 10000 ] In Testing [ 10301 ]
            anel Anel Husakovic made changes -
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status Stalled [ 10000 ] In Review [ 10002 ]

            I mean that thd->security_ctx->priv_user corresponds to thd->security_ctx->priv_host, there is a row in the mysql.user where username is thd->security_ctx->priv_user and hostname is thd->security_ctx->priv_host.

            While user corresponds to host. They were both specified in the command SET DEFAULT ROLE FOR.

            A pair or user and thd->security_ctx->priv_host is a wrong combination, it does not necessarily correspond to anything in particular.

            serg Sergei Golubchik added a comment - I mean that thd->security_ctx->priv_user corresponds to thd->security_ctx->priv_host , there is a row in the mysql.user where username is thd->security_ctx->priv_user and hostname is thd->security_ctx->priv_host . While user corresponds to host . They were both specified in the command SET DEFAULT ROLE FOR . A pair or user and thd->security_ctx->priv_host is a wrong combination, it does not necessarily correspond to anything in particular.
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]

            Hi Serg can you please review 585cd1f52e75e3f ?

            anel Anel Husakovic added a comment - Hi Serg can you please review 585cd1f52e75e3f ?
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status Stalled [ 10000 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            anel Anel Husakovic made changes -
            Status Stalled [ 10000 ] Open [ 1 ]

            anel,

            Is it supposed to be in "in review"?

            elenst Elena Stepanova added a comment - anel , Is it supposed to be in "in review"?

            Yes I think it should be. I will update with test case related to this MDEV only. Thank you elenst.

            anel Anel Husakovic added a comment - Yes I think it should be. I will update with test case related to this MDEV only. Thank you elenst .
            anel Anel Husakovic made changes -
            anel Anel Husakovic made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status Confirmed [ 10101 ] In Review [ 10002 ]

            you wrote

            if (!host)
            

            do you have a test case for that condition? I mean, a test case where host == NULL ?

            serg Sergei Golubchik added a comment - you wrote if (!host) do you have a test case for that condition? I mean, a test case where host == NULL ?
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            anel Anel Husakovic made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]

            Hi Serg, yes I have update the test case for PR 2362

            anel Anel Husakovic added a comment - Hi Serg, yes I have update the test case for PR 2362
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik added a comment - https://github.com/MariaDB/server/pull/2362#discussion_r1270317522
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            anel Anel Husakovic added a comment - - edited

            Have updated PR 2362 per review.
            Added additional commit for testing the grants of anonymous user.

            anel Anel Husakovic added a comment - - edited Have updated PR 2362 per review. Added additional commit for testing the grants of anonymous user.
            anel Anel Husakovic made changes -
            Assignee Anel Husakovic [ anel ] Sergei Golubchik [ serg ]
            Status Stalled [ 10000 ] In Review [ 10002 ]
            serg Sergei Golubchik added a comment - - edited

            7349633b2c59 is ok to push

            you can squash both commits into one or commit separately, as you like

            serg Sergei Golubchik added a comment - - edited 7349633b2c59 is ok to push you can squash both commits into one or commit separately, as you like
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Anel Husakovic [ anel ]
            Status In Review [ 10002 ] Stalled [ 10000 ]

            Thanks pushed with ee773753778e741c.

            anel Anel Husakovic added a comment - Thanks pushed with ee773753778e741c .
            anel Anel Husakovic made changes -
            Component/s Authentication and Privilege System [ 13101 ]
            Fix Version/s 10.5.23 [ 29012 ]
            Fix Version/s 10.6.16 [ 29014 ]
            Fix Version/s 10.10.7 [ 29018 ]
            Fix Version/s 11.0.4 [ 29021 ]
            Fix Version/s 11.1.3 [ 29023 ]
            Fix Version/s 11.2.2 [ 29035 ]
            Fix Version/s 11.3.1 [ 29416 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            JIraAutomate JiraAutomate made changes -
            Fix Version/s 10.11.6 [ 29020 ]
            dbart Daniel Bartholomew made changes -
            Fix Version/s 10.5.24 [ 29517 ]
            Fix Version/s 10.6.17 [ 29518 ]
            Fix Version/s 10.11.7 [ 29519 ]
            Fix Version/s 11.0.5 [ 29520 ]
            Fix Version/s 11.1.4 [ 29024 ]
            Fix Version/s 11.2.3 [ 29521 ]
            Fix Version/s 11.3.2 [ 29522 ]
            Fix Version/s 10.5.23 [ 29012 ]
            Fix Version/s 10.6.16 [ 29014 ]
            Fix Version/s 10.10.7 [ 29018 ]
            Fix Version/s 10.11.6 [ 29020 ]
            Fix Version/s 11.0.4 [ 29021 ]
            Fix Version/s 11.1.3 [ 29023 ]
            Fix Version/s 11.2.2 [ 29035 ]
            Fix Version/s 11.3.1 [ 29416 ]

            People

              anel Anel Husakovic
              markus makela markus makela
              Votes:
              1 Vote for this issue
              Watchers:
              5 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.