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

            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.

            Hi Serg can you please review 585cd1f52e75e3f ?

            anel Anel Husakovic added a comment - Hi Serg can you please review 585cd1f52e75e3f ?

            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 .

            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 ?

            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
            serg Sergei Golubchik added a comment - https://github.com/MariaDB/server/pull/2362#discussion_r1270317522
            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.
            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

            Thanks pushed with ee773753778e741c.

            anel Anel Husakovic added a comment - Thanks pushed with ee773753778e741c .

            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.