StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
8.98k stars 1.8k forks source link

An error occurs when the `root` role is assigned. #44198

Closed yongbingwang closed 2 weeks ago

yongbingwang commented 7 months ago

Use Non-root user grant the Root role to other user, error occurs.

Steps to reproduce the behavior (Required)

  1. login with root, create user wybing_user_admin, grant user_admin to wybing_user_admin.
    
    ☁  ~ [main] ⚡  mysql -h172.26.80.144 -uroot -P9030
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 67
    Server version: 5.1.0 main-fcaff5a

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create user wybing_user_admin; Query OK, 0 rows affected (0.01 sec)

mysql> grant user_admin to wybing_user_admin; Query OK, 0 rows affected (0.00 sec)

mysql> set default role user_admin to wybing_user_admin; Query OK, 0 rows affected (0.00 sec)

2. login with `wybing_user_admin`, create role `Root` and user `test`, grant role `Root` to user `test`.
```sql
☁  ~ [main] ⚡  mysql -h172.26.80.144 -uwybing_user_admin -P9030
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 68
Server version: 5.1.0 main-fcaff5a

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create role Root;
Query OK, 0 rows affected (0.01 sec)

mysql> create user test;
Query OK, 0 rows affected (0.00 sec)

mysql> grant Root to test;
ERROR 1064 (HY000): Getting analyzing error. Detail message: Can not grant root or cluster_admin role except root user.
  1. login with wybing_user_admin, create role Test, grant role Test to user test.
    
    ☁  ~ [main] ⚡  mysql -h172.26.80.144 -uwybing_user_admin -P9030
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 70
    Server version: 5.1.0 main-fcaff5a

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create role Test; Query OK, 0 rows affected (0.01 sec)

mysql> grant Test to test; Query OK, 0 rows affected (0.01 sec)

4. login with `root`, grant role `Root` to user test.
```sql
☁  ~ [main] ⚡  mysql -h172.26.80.144 -uroot -P9030
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 69
Server version: 5.1.0 main-fcaff5a

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant Root to test;
Query OK, 0 rows affected (0.01 sec)

Expected behavior (Required)

Real behavior (Required)

StarRocks version (Required)

github-actions[bot] commented 1 month ago

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!