-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-10112: mysql_secure_installation should use GRANT, REVOKE, etc for galera support #4775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kjarir
wants to merge
4
commits into
MariaDB:11.4
Choose a base branch
from
kjarir:MDEV-10112-galera-safe-secure-installation
base: 11.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+270
−15
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d598478
MDEV-10112: mysql_secure_installation: use DDL instead of DML for Gal…
kjarir bb84567
Merge branch '11.4' into MDEV-10112-galera-safe-secure-installation
kjarir 52cbcf2
Merge branch '11.4' into MDEV-10112-galera-safe-secure-installation
kjarir 426aca8
MDEV-10112: mysql_secure_installation should use DDL for Galera compa…
kjarir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # | ||
| # MDEV-10112: mysql_secure_installation should use DDL (GRANT, REVOKE, etc) | ||
| # instead of DML for Galera compatibility | ||
| # | ||
| # | ||
| # Setup dummy accounts and database to be secured | ||
| # | ||
| CREATE USER 'root'@'remote_host' IDENTIFIED BY 'pass'; | ||
| CREATE USER 'test_user'@'localhost' IDENTIFIED BY 'pass'; | ||
| CREATE DATABASE msi_test_db; | ||
| GRANT ALL PRIVILEGES ON msi_test_db.* TO 'test_user'@'localhost'; | ||
| GRANT ALL PRIVILEGES ON test.* TO 'test_user'@'localhost'; | ||
| # Verify: remote root account removed | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| user host | ||
| # Verify: test database removed | ||
| SHOW DATABASES LIKE 'test'; | ||
| Database (test) | ||
| # Verify: test DB privileges removed from mysql.db | ||
| SELECT user, host, db FROM mysql.db WHERE db = 'test' ORDER BY user, host, db; | ||
| user host db | ||
| # Cleanup | ||
| DROP USER 'test_user'@'localhost'; | ||
| DROP DATABASE msi_test_db; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --source include/not_windows.inc | ||
| --source include/not_embedded.inc | ||
| --source include/save_sys_tables.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-10112: mysql_secure_installation should use DDL (GRANT, REVOKE, etc) | ||
| --echo # instead of DML for Galera compatibility | ||
| --echo # | ||
|
|
||
| --echo # | ||
| --echo # Setup dummy accounts and database to be secured | ||
| --echo # | ||
| CREATE USER 'root'@'remote_host' IDENTIFIED BY 'pass'; | ||
| CREATE USER 'test_user'@'localhost' IDENTIFIED BY 'pass'; | ||
|
|
||
| # 'test' is a special database in MTR, ensuring it exists for the script | ||
| --disable_warnings | ||
| CREATE DATABASE IF NOT EXISTS test; | ||
| --enable_warnings | ||
|
|
||
| # Create a custom database to ensure we don't interfere with other tests | ||
| CREATE DATABASE msi_test_db; | ||
| GRANT ALL PRIVILEGES ON msi_test_db.* TO 'test_user'@'localhost'; | ||
|
|
||
| # Verify the script's REVOKE logic by granting on 'test' | ||
| GRANT ALL PRIVILEGES ON test.* TO 'test_user'@'localhost'; | ||
|
|
||
| # Prepare input for the script | ||
| # 1. [Empty] - current root password | ||
| # 2. n - Enable unix_socket? | ||
| # 3. n - Set root password? | ||
| # 4. Y - Remove anonymous users? | ||
| # 5. Y - Disallow root login remotely? | ||
| # 6. Y - Remove test database? | ||
| # 7. Y - Reload privilege tables? | ||
| --write_file $MYSQLTEST_VARDIR/tmp/msi_input.txt | ||
|
|
||
| n | ||
| n | ||
| Y | ||
| Y | ||
| Y | ||
| Y | ||
| EOF | ||
|
|
||
| # Run the script | ||
| --exec $MYSQL_SECURE_INSTALLATION --basedir=$MYSQL_BINDIR -S $MASTER_MYSOCK < $MYSQLTEST_VARDIR/tmp/msi_input.txt > $MYSQLTEST_VARDIR/tmp/msi.log 2>&1 | ||
|
|
||
| --remove_file $MYSQLTEST_VARDIR/tmp/msi_input.txt | ||
| --remove_file $MYSQLTEST_VARDIR/tmp/msi.log | ||
|
|
||
| --echo # Verify: remote root account removed | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
|
|
||
| --echo # Verify: test database removed | ||
| SHOW DATABASES LIKE 'test'; | ||
|
|
||
| --echo # Verify: test DB privileges removed from mysql.db | ||
| SELECT user, host, db FROM mysql.db WHERE db = 'test' ORDER BY user, host, db; | ||
|
|
||
| # Cleanup | ||
| # The script already dropped 'root'@'remote_host' and 'test' DB. | ||
| DROP USER 'test_user'@'localhost'; | ||
| DROP DATABASE msi_test_db; | ||
|
|
||
| --source include/restore_sys_tables.inc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
mysql-test/suite/galera/r/galera_secure_installation.result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # | ||
| # MDEV-10112: mysql_secure_installation should use DDL (GRANT, REVOKE, etc) | ||
| # instead of DML for Galera compatibility | ||
| # | ||
| # On node_1 | ||
| # | ||
| # Setup remote root account to be removed | ||
| # | ||
| CREATE USER 'root'@'remote_host' IDENTIFIED BY 'pass'; | ||
| GRANT ALL ON *.* TO 'root'@'remote_host'; | ||
| # On node_2 | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| user host | ||
| root remote_host | ||
| SHOW DATABASES LIKE 'test'; | ||
| Database (test) | ||
| test | ||
| # Verify on node_1: remote root is gone | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| user host | ||
| # Verify on node_1: test database is gone | ||
| SHOW DATABASES LIKE 'test'; | ||
| Database (test) | ||
| # Now verify on node_2 (replication check) | ||
| # Verify on node_2: remote root is gone (replicated) | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| user host | ||
| # Verify on node_2: test database is gone (replicated) | ||
| SHOW DATABASES LIKE 'test'; | ||
| Database (test) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --source include/galera_cluster.inc | ||
| --source include/have_innodb.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-10112: mysql_secure_installation should use DDL (GRANT, REVOKE, etc) | ||
| --echo # instead of DML for Galera compatibility | ||
| --echo # | ||
|
|
||
| --connection node_1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remarks as the other test. |
||
| --echo # | ||
| --echo # Setup remote root account to be removed | ||
| --echo # | ||
| CREATE USER 'root'@'remote_host' IDENTIFIED BY 'pass'; | ||
| GRANT ALL ON *.* TO 'root'@'remote_host'; | ||
|
|
||
| # 'test' is a special database in MTR, ensuring it exists for the script | ||
| --disable_warnings | ||
| CREATE DATABASE IF NOT EXISTS test; | ||
| --enable_warnings | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 1 FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host' | ||
| --source include/wait_condition.inc | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| SHOW DATABASES LIKE 'test'; | ||
|
|
||
| --connection node_1 | ||
| # Prepare input: | ||
| # 1. [Empty] - current root password | ||
| # 2. n - Enable unix_socket? | ||
| # 3. n - Set root password? | ||
| # 4. n - Remove anonymous users? | ||
| # 5. Y - Disallow root login remotely? | ||
| # 6. Y - Remove test database? | ||
| # 7. Y - Reload privilege tables? | ||
|
|
||
| --write_file $MYSQLTEST_VARDIR/tmp/msi_galera_input.txt | ||
|
|
||
| n | ||
| n | ||
| n | ||
| Y | ||
| Y | ||
| Y | ||
| EOF | ||
|
|
||
| --exec $MYSQL_SECURE_INSTALLATION --basedir=$MYSQL_BINDIR -S $MASTER_MYSOCK < $MYSQLTEST_VARDIR/tmp/msi_galera_input.txt > $MYSQLTEST_VARDIR/tmp/msi_galera.log 2>&1 | ||
|
|
||
| --remove_file $MYSQLTEST_VARDIR/tmp/msi_galera_input.txt | ||
| --remove_file $MYSQLTEST_VARDIR/tmp/msi_galera.log | ||
|
|
||
| --echo # Verify on node_1: remote root is gone | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| --echo # Verify on node_1: test database is gone | ||
| SHOW DATABASES LIKE 'test'; | ||
|
|
||
| --echo # Now verify on node_2 (replication check) | ||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host' | ||
| --source include/wait_condition.inc | ||
| --echo # Verify on node_2: remote root is gone (replicated) | ||
| SELECT user, host FROM mysql.global_priv WHERE user = 'root' AND host = 'remote_host'; | ||
| --echo # Verify on node_2: test database is gone (replicated) | ||
| SHOW DATABASES LIKE 'test'; | ||
|
|
||
| --source include/galera_end.inc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be at the top. However many galera tests would be doing these already.