-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-39648: wsrep_sst_rsync.sh: apply safe() to joiner-supplied parameters #5092
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
Closed
+142
−2
Closed
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions
27
mysql-test/suite/galera/r/galera_sst_rsync_encrypt_with_key_server.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,27 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| SELECT 1; | ||
| 1 | ||
| 1 | ||
| connection node_2; | ||
| FOUND 1 /wsrep_sst_rsync/ in mysqld.1.err | ||
| connection node_1; | ||
| call mtr.add_suppression('Invalid value for WSREP_SST_OPT_REMOTE_USER'); | ||
| call mtr.add_suppression('Failed to read from: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Process completed with error: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Command did not run: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Error while getting data from donor node'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('Removing .*/sst_in_progress'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
| connection node_2; | ||
| connection node_1; | ||
| FOUND 1 /Invalid value for WSREP_SST_OPT_REMOTE_USER/ in mysqld.1.err | ||
| connection node_2; | ||
| # restart | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('State transfer to .* failed'); |
13 changes: 13 additions & 0 deletions
13
mysql-test/suite/galera/t/galera_sst_rsync_encrypt_with_key_server.cnf
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,13 @@ | ||
| !include ../galera_2nodes.cnf | ||
|
|
||
| [mysqld] | ||
| wsrep_sst_method=rsync | ||
| wsrep_sst_auth="root:" | ||
| wsrep_debug=1 | ||
|
|
||
| ssl-cert[email protected]_TEST_DIR/std_data/server-cert.pem | ||
| ssl-key[email protected]_TEST_DIR/std_data/server-key.pem | ||
| ssl-ca[email protected]_TEST_DIR/std_data/cacert.pem | ||
|
|
||
| [sst] | ||
| ssl-mode=VERIFY_CA |
99 changes: 99 additions & 0 deletions
99
mysql-test/suite/galera/t/galera_sst_rsync_encrypt_with_key_server.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,99 @@ | ||
| # | ||
| # Verifies that wsrep_sst_rsync.sh rejects a joiner-supplied certificate | ||
| # whose CN contains shell-unsafe characters. | ||
| # | ||
| # Brings up a 2-node cluster with rsync SST and ssl-mode=VERIFY_CA, then | ||
| # forces a fresh SST on node_2 using std_data/server-new-cert.pem -- a | ||
| # cert whose CN intentionally contains shell metacharacters. Confirms | ||
| # that the donor (node_1) logs | ||
| # "Invalid value for WSREP_SST_OPT_REMOTE_USER" | ||
| # i.e. the rsync SST script refuses the value rather than interpolating | ||
| # it into stunnel.conf or the rsync magic file. | ||
| # | ||
|
|
||
| --source include/galera_cluster.inc | ||
| --source include/have_innodb.inc | ||
|
|
||
| SELECT 1; | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'WSREP_LOCAL_STATE_COMMENT' | ||
| --source include/wait_condition.inc | ||
|
|
||
| # Confirm the initial SST went via rsync + stunnel (sanity check for the | ||
| # test configuration). | ||
| --let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err | ||
| --let SEARCH_PATTERN = wsrep_sst_rsync | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
|
|
||
| # Reject shell-unsafe joiner-supplied auth (rsync) | ||
|
|
||
| # Suppressions are per-server. node_1 will log the donor-side rejection | ||
| # ("Invalid value for WSREP_SST_OPT_REMOTE_USER"); node_2 will log the | ||
| # joiner-side "Will never receive state" abort. Add to both. | ||
| --connection node_1 | ||
| call mtr.add_suppression('Invalid value for WSREP_SST_OPT_REMOTE_USER'); | ||
| call mtr.add_suppression('Failed to read from: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Process completed with error: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('Command did not run: wsrep_sst_rsync'); | ||
| call mtr.add_suppression('State transfer to .* failed'); | ||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Error while getting data from donor node'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('Removing .*/sst_in_progress'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
|
|
||
| --connection node_2 | ||
| --source include/shutdown_mysqld.inc | ||
|
|
||
| # force SST again | ||
| --remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat | ||
| # using a cert with shell-unsafe CN | ||
| --exec echo '[mysqld.2]' >> $MYSQLTEST_VARDIR/my.cnf | ||
| --exec echo ssl-cert=$MYSQL_TEST_DIR/std_data/server-new-cert.pem >> $MYSQLTEST_VARDIR/my.cnf | ||
| --exec echo ssl-key=$MYSQL_TEST_DIR/std_data/server-new-key.pem >> $MYSQLTEST_VARDIR/my.cnf | ||
|
|
||
| # start the server | ||
| # Joiner mariadbd exits when SST is aborted; the exit code varies by | ||
| # platform (clean 0 on some systems, signalled 134 / 1 on others). | ||
| --error 0,1,134 | ||
| --exec $MYSQLD_LAST_CMD | ||
| # the donor refused the SST request | ||
|
|
||
| --connection node_1 | ||
| # safe() in wsrep_sst_common.sh logs this when it rejects the joiner CN; | ||
| # wsrep_sst_rsync.sh wraps the joiner-supplied REMOTE_USER with $(safe ..) | ||
| # at line 249 so the value never reaches the stunnel.conf heredoc. | ||
| --let SEARCH_PATTERN = Invalid value for WSREP_SST_OPT_REMOTE_USER | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| # cleanup | ||
| # Kill joiner's stunnel / rsync that may linger after the aborted SST. | ||
| # Use a perl block because --exec with pkill -f matches the mtr cmdline | ||
| # itself (which contains the pattern) and tears down the wrong process. | ||
| perl; | ||
| open(my $fh, '-|', 'ps', '-eo', 'pid,args') or die "ps: $!"; | ||
| while (<$fh>) { | ||
| next unless /server-new-cert/; | ||
| next unless /^\s*(\d+)\s+(?:.*\/)?(stunnel|socat|rsync)\b/; | ||
| kill 'TERM', $1; | ||
| } | ||
| close $fh; | ||
| EOF | ||
| --exec echo ssl-cert=$MYSQL_TEST_DIR/std_data/server-cert.pem >> $MYSQLTEST_VARDIR/my.cnf | ||
| --exec echo ssl-key=$MYSQL_TEST_DIR/std_data/server-key.pem >> $MYSQLTEST_VARDIR/my.cnf | ||
|
|
||
| # Switch back to node_2 before restarting it; the connection associates | ||
| # with the soon-to-be-restarted server so mtr auto-reconnects and the | ||
| # wait_condition + late suppressions land on the new instance. | ||
| --connection node_2 | ||
| --source $MYSQL_TEST_DIR/include/start_mysqld.inc | ||
|
|
||
| --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
| --source include/wait_condition.inc | ||
|
|
||
| call mtr.add_suppression('Will never receive state. Need to abort'); | ||
| call mtr.add_suppression('Parent mysqld process .* terminated unexpectedly'); | ||
| call mtr.add_suppression('Cleanup after exit with status'); | ||
| call mtr.add_suppression('State transfer to .* failed'); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.