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

Appending SELECT privilege not applied on show columns and show index

    XMLWordPrintable

Details

    Description

      When the user is created without SELECT privilege and after that applied the SELECT privilege nothing changes:

      create database db;
      create user foo@localhost;
      grant create on db.* to foo@localhost;
       
      --connect (con1,localhost,foo,,db)
      create table t (a int, key(a));
      show create table t;
      --error ER_TABLEACCESS_DENIED_ERROR
      show columns in t;
      --error ER_TABLEACCESS_DENIED_ERROR
      show index in t;
       
      # Give the user select privilege
      --connection default
      grant select on db.* to foo@localhost;
       
      --connection con1
      show grants for current_user;
      Grants for foo@localhost
      GRANT USAGE ON *.* TO `foo`@`localhost`
      GRANT SELECT, CREATE ON `db`.* TO `foo`@`localhost`
       
      # This should be visible but is not - bug! still ER_TABLEACCESS_DENIED_ERROR
      show columns in t;
      8: query 'show columns in t' failed: ER_TABLEACCESS_DENIED_ERROR (1142): SELECT command denied to user 'foo'@'localhost' for table 't'
       
      # This should be visible but is not - bug! still ER_TABLEACCESS_DENIED_ERROR
      show index in t;
       
      # Cleanup
      --disconnect con1
      --connection default
      drop database db;
      drop user foo@localhost;
      

      However if we create new user that has just SELECT priv it works

      --connection default
      create user bar@localhost;
      grant select on db.* to bar@localhost;
      show grants for bar@localhost;
      Grants for bar@localhost
      GRANT USAGE ON *.* TO `bar`@`localhost`
      GRANT SELECT ON `db`.* TO `bar`@`localhost`
       
      --connect (con2,localhost,bar,,db)
      show index in t;
      Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	CardinalitySub_part	Packed	Null	Index_type	Comment	Index_comment	Ignored
      t	1	a	1	a	A	NULL	NULL	NULL	YES	BTREE			NO
      show columns in t;
      Field	Type	Null	Key	Default	Extra
      a	int(11)	YES	MUL	NULL	
      

      Attachments

        Issue Links

          Activity

            People

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