Skip to content

Grant option is silently dropped when editing privileges on MySQL 8.0.11+ #20521

Open

Description

@cB-Abhinav-Gautam

Describe the bug

On MySQL (and Percona) 8.0.11 or newer, ticking Grant while editing a user's privileges has no effect. The grant option is never given. This happens at every level: global, database, table and routine. Nothing reports an error, and after saving, the checkbox is unticked again.

This is the root cause of #19605, which reports it for database-level privileges. It is not limited to that level, though.

To Reproduce

  1. Use a MySQL 8.0.11+ server (reproduced on 8.4).
  2. Server → User accounts → Edit privileges for any user → Database → pick a database.
  3. Tick e.g. SELECT and GRANT, then press Go.
  4. phpMyAdmin runs:
    REVOKE ALL PRIVILEGES ON `db`.* FROM 'u'@'h';
    GRANT SELECT ON `db`.* TO 'u'@'h';
    ALTER USER 'u'@'h' ;
  5. SHOW GRANTS FOR 'u'@'h' lists GRANT SELECT ON db.* TO u@h, without WITH GRANT OPTION.

The same happens on the Global tab (GRANT ... ON *.* TO 'u'@'h'; + ALTER USER 'u'@'h' REQUIRE NONE;).

Expected behavior

The GRANT statement ends with WITH GRANT OPTION, as it does on MySQL < 8.0.11 and on MariaDB:

GRANT SELECT ON `db`.* TO 'u'@'h' WITH GRANT OPTION;

Cause

Since 8.0.11, Privileges::generateQueriesForUpdatePrivileges() moves the WITH clause from the GRANT to an ALTER USER statement. getWithClauseForAddUserAndUpdatePrivs() then correctly omits GRANT OPTION, because ALTER USER cannot set it. However, nothing appends WITH GRANT OPTION to the GRANT statement instead. The add-user path (getSqlQueriesForDisplayAndAddUser()) already handles this correctly.

The existing test testUpdatePrivilegesAfterMySql8Dot11 currently asserts the buggy output: it posts Grant_priv=Y but expects a GRANT without the grant option.

Server configuration

  • phpMyAdmin: QA_5_2 and master (a57149e); the code is the same in 5.2.x
  • MySQL 8.4 (any MySQL/Percona >= 8.0.11)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions