Skip to content

Commit 8bbe3a3

Browse files
committed
MDEV-21194: mariadb-install-db doesn't properly grant proxy privileges to all created user accounts
mariadb-install-db --auth-root-authentication-method=normal created 4 root accounts by default, but only two of these had PROXY privilege granted. mariadb-install-db (default option --auth-root-authentication-method=socket) as non-root user also didn't grant PROXY priv to the created nonroot@localhost user. To fix this, in mysql_system_tables_data.sql, we re-use tmp_user_nopasswd as this contains the list of all root users. REPLACE INTO tmp_proxies_priv SELECT @current_hostname, IFNULL(@auth_root_socket, 'root') creates the $user@$current_host but will not error if @auth_root_socket is null. Note @current_hostname lines are filtered out with --cross-bootstrap in mariadb-install-db so it was needed to include this expression for consistency. Like the existing mysql_system_tables.sql is used to create teh $user@localhost proxies_priv. Test cases roles.acl_statistics, perfschema,privilege_table_io depends on the number of proxy users. After: --auth-root-authentication-method=normal: MariaDB [mysql]> select * from global_priv; +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------+ | Host | User | Priv | +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------+ | localhost | mariadb.sys | {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":true,"password_last_changed":0} | | localhost | root | {"access":18446744073709551615} | | bark | root | {"access":18446744073709551615} | | 127.0.0.1 | root | {"access":18446744073709551615} | | ::1 | root | {"access":18446744073709551615} | | localhost | | {} | | bark | | {} | +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------+ 7 rows in set (0.001 sec) MariaDB [mysql]> select * from proxies_priv; +-----------+------+--------------+--------------+------------+---------+---------------------+ | Host | User | Proxied_host | Proxied_user | With_grant | Grantor | Timestamp | +-----------+------+--------------+--------------+------------+---------+---------------------+ | localhost | root | | | 1 | | 2023-07-10 12:12:24 | | 127.0.0.1 | root | | | 1 | | 2023-07-10 12:12:24 | | ::1 | root | | | 1 | | 2023-07-10 12:12:24 | | bark | root | | | 1 | | 2023-07-10 12:12:24 | +-----------+------+--------------+--------------+------------+---------+---------------------+ --auth-root-authentication-method=socket: MariaDB [mysql]> select * from proxies_priv; +-----------+------+--------------+--------------+------------+---------+---------------------+ | Host | User | Proxied_host | Proxied_user | With_grant | Grantor | Timestamp | +-----------+------+--------------+--------------+------------+---------+---------------------+ | localhost | root | | | 1 | | 2023-07-10 12:11:55 | | localhost | dan | | | 1 | | 2023-07-10 12:11:55 | | bark | dan | | | 1 | | 2023-07-10 12:11:55 | +-----------+------+--------------+--------------+------------+---------+---------------------+ 3 rows in set (0.017 sec) MariaDB [mysql]> select * from global_priv; +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | Host | User | Priv | +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | localhost | mariadb.sys | {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":true,"password_last_changed":0} | | localhost | root | {"access":18446744073709551615,"plugin":"mysql_native_password","authentication_string":"invalid","auth_or":[{},{"plugin":"unix_socket"}]} | | localhost | dan | {"access":18446744073709551615,"plugin":"mysql_native_password","authentication_string":"invalid","auth_or":[{},{"plugin":"unix_socket"}]} | | localhost | | {} | | bark | | {} | +-----------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------+ 5 rows in set (0.000 sec) MariaDB [mysql]> show grants; +----------------------------------------------------------------------------------------------------------------------------------------+ | Grants for dan@localhost | +----------------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO `dan`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket WITH GRANT OPTION | | GRANT PROXY ON ''@'%' TO 'dan'@'localhost' WITH GRANT OPTION | +----------------------------------------------------------------------------------------------------------------------------------------+
1 parent 18990f0 commit 8bbe3a3

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

mysql-test/suite/perfschema/r/privilege_table_io.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ wait/io/table/sql/handler handler.cc: TABLE mysql db fetch NULL
108108
wait/io/table/sql/handler handler.cc: TABLE mysql proxies_priv fetch NULL
109109
wait/io/table/sql/handler handler.cc: TABLE mysql proxies_priv fetch NULL
110110
wait/io/table/sql/handler handler.cc: TABLE mysql proxies_priv fetch NULL
111+
wait/io/table/sql/handler handler.cc: TABLE mysql proxies_priv fetch NULL
112+
wait/io/table/sql/handler handler.cc: TABLE mysql proxies_priv fetch NULL
111113
wait/io/table/sql/handler handler.cc: TABLE mysql roles_mapping fetch NULL
112114
wait/io/table/sql/handler handler.cc: TABLE mysql tables_priv fetch NULL
113115
wait/io/table/sql/handler handler.cc: TABLE mysql tables_priv fetch NULL

mysql-test/suite/roles/acl_statistics.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Acl_function_grants 0
66
Acl_procedure_grants 0
77
Acl_package_spec_grants 0
88
Acl_package_body_grants 0
9-
Acl_proxy_users 2
9+
Acl_proxy_users 4
1010
Acl_role_grants 0
1111
Acl_roles 0
1212
Acl_table_grants 1
@@ -25,7 +25,7 @@ PROCEDURE_GRANTS
2525
0
2626
SELECT count(*) PROXY_USERS from mysql.proxies_priv;
2727
PROXY_USERS
28-
2
28+
4
2929
SELECT count(*) ROLE_GRANTS from mysql.roles_mapping;
3030
ROLE_GRANTS
3131
0
@@ -71,7 +71,7 @@ Acl_function_grants 3
7171
Acl_procedure_grants 2
7272
Acl_package_spec_grants 0
7373
Acl_package_body_grants 0
74-
Acl_proxy_users 3
74+
Acl_proxy_users 5
7575
Acl_role_grants 4
7676
Acl_roles 2
7777
Acl_table_grants 3
@@ -90,7 +90,7 @@ PROCEDURE_GRANTS
9090
2
9191
SELECT count(*) PROXY_USERS from mysql.proxies_priv;
9292
PROXY_USERS
93-
3
93+
5
9494
SELECT count(*) ROLE_GRANTS from mysql.roles_mapping;
9595
ROLE_GRANTS
9696
4

scripts/mysql_system_tables.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ set @had_proxies_priv_table= @@warning_count != 0;
303303
-- and for upgrades
304304
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
305305
INSERT INTO tmp_proxies_priv VALUES ('localhost', 'root', '', '', TRUE, '', now());
306+
REPLACE INTO tmp_proxies_priv SELECT 'localhost',IFNULL(@auth_root_socket, 'root'), '', '', TRUE, '', now() FROM DUAL;
306307
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
307308
DROP TABLE tmp_proxies_priv;
308309

scripts/mysql_system_tables_data.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ IF @auth_root_socket is not null THEN
4747

4848
INSERT INTO global_priv SELECT * FROM tmp_user_nopasswd WHERE @had_user_table=0 AND @auth_root_socket IS NULL;
4949
INSERT INTO global_priv SELECT * FROM tmp_user_socket WHERE @had_user_table=0 AND @auth_root_socket IS NOT NULL;
50-
DROP TABLE tmp_user_nopasswd, tmp_user_socket;
5150

5251
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
53-
INSERT INTO tmp_proxies_priv SELECT @current_hostname, 'root', '', '', TRUE, '', now() FROM DUAL WHERE @current_hostname != 'localhost';
52+
INSERT INTO tmp_proxies_priv SELECT Host, User, '', '', TRUE, '', now() FROM tmp_user_nopasswd WHERE Host != 'localhost' AND @auth_root_socket IS NULL;
53+
REPLACE INTO tmp_proxies_priv SELECT @current_hostname, IFNULL(@auth_root_socket, 'root'), '', '', TRUE, '', now() FROM DUAL WHERE @current_hostname != 'localhost';
5454
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
55-
DROP TABLE tmp_proxies_priv;
55+
DROP TABLE tmp_user_nopasswd, tmp_user_socket, tmp_proxies_priv;

0 commit comments

Comments
 (0)