Commit 7ba12d42 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-34434 Hide password passed on commandline from xtrabackup_info

refine mariadb-backup password zapping check
parent d2051816
...@@ -1934,9 +1934,17 @@ char *make_argv(char *buf, size_t len, int argc, char **argv) ...@@ -1934,9 +1934,17 @@ char *make_argv(char *buf, size_t len, int argc, char **argv)
while (argc > 0 && left > 0) while (argc > 0 && left > 0)
{ {
arg = *argv; arg = *argv;
if (strncmp(*argv, "--password", strlen("--password")) == 0) { if (strncmp(*argv, STRING_WITH_LEN("--password=")) == 0) {
arg = "--password=..."; arg = "--password=...";
} else
if (strcmp(*argv, "--password") == 0) {
arg = "--password ...";
++argv; --argc;
} else
if (strncmp(*argv, STRING_WITH_LEN("-p")) == 0) {
arg = "-p...";
} }
uint l= snprintf(buf + len - left, left, uint l= snprintf(buf + len - left, left,
"%s%c", arg, argc > 1 ? ' ' : 0); "%s%c", arg, argc > 1 ? ' ' : 0);
++argv; --argc; ++argv; --argc;
......
CREATE user backup@localhost IDENTIFIED BY 'xyz'; CREATE user backup@localhost IDENTIFIED BY 'xyz';
NOT FOUND /missing required privilege/ in backup.log NOT FOUND /missing required privilege/ in backup.log
NOT FOUND /xyz/ in xtrabackup_info
FOUND 1 /missing required privilege RELOAD/ in backup.log FOUND 1 /missing required privilege RELOAD/ in backup.log
FOUND 1 /missing required privilege PROCESS/ in backup.log FOUND 1 /missing required privilege PROCESS/ in backup.log
FOUND 1 /GRANT USAGE ON/ in backup.log FOUND 1 /GRANT USAGE ON/ in backup.log
GRANT RELOAD, PROCESS on *.* to backup@localhost; GRANT RELOAD, PROCESS on *.* to backup@localhost;
NOT FOUND /missing required privilege/ in backup.log NOT FOUND /missing required privilege/ in backup.log
NOT FOUND /xyz/ in xtrabackup_info
FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log
GRANT REPLICA MONITOR ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost;
NOT FOUND /missing required privilege/ in backup.log NOT FOUND /missing required privilege/ in backup.log
NOT FOUND /xyz/ in xtrabackup_info
REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
NOT FOUND /xyz/ in xtrabackup_info
FOUND 1 /missing required privilege CONNECTION ADMIN/ in backup.log FOUND 1 /missing required privilege CONNECTION ADMIN/ in backup.log
GRANT CONNECTION ADMIN ON *.* TO backup@localhost; GRANT CONNECTION ADMIN ON *.* TO backup@localhost;
NOT FOUND /missing required privilege/ in backup.log NOT FOUND /missing required privilege/ in backup.log
NOT FOUND /xyz/ in xtrabackup_info
FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log
FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log
GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost;
GRANT REPLICA MONITOR ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost;
NOT FOUND /missing required privilege/ in backup.log NOT FOUND /missing required privilege/ in backup.log
NOT FOUND /xyz/ in xtrabackup_info
DROP USER backup@localhost; DROP USER backup@localhost;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
let $info=$MYSQLTEST_VARDIR/tmp/backup/xtrabackup_info;
let $log=$MYSQLTEST_VARDIR/tmp/backup.log;
CREATE user backup@localhost IDENTIFIED BY 'xyz'; CREATE user backup@localhost IDENTIFIED BY 'xyz';
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log;
# backup possible for unprivileges user, with --no-lock # backup possible for unprivileges user, with --no-lock
--disable_result_log --disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_FILE=$log
--let SEARCH_PATTERN= missing required privilege --let SEARCH_PATTERN= missing required privilege
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
# backup fails without --no-lock, because of FTWRL # backup fails without --no-lock, because of FTWRL
...@@ -17,6 +22,7 @@ error 1; ...@@ -17,6 +22,7 @@ error 1;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_FILE=$log
--let SEARCH_PATTERN= missing required privilege RELOAD --let SEARCH_PATTERN= missing required privilege RELOAD
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= missing required privilege PROCESS --let SEARCH_PATTERN= missing required privilege PROCESS
...@@ -30,16 +36,20 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backu ...@@ -30,16 +36,20 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backu
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege --let SEARCH_PATTERN= missing required privilege
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
# MDEV-23607 Warning: missing required privilege REPLICATION CLIENT # MDEV-23607 Warning: missing required privilege REPLICATION CLIENT
# --slave-info and --galera-info require REPLICA MONITOR # --slave-info and --galera-info require REPLICA MONITOR
--disable_result_log --disable_result_log
error 1; error 1;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup --password xyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup --password=xyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
rmdir $targetdir; rmdir $targetdir;
--let SEARCH_FILE=$log
--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR --let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
...@@ -49,6 +59,9 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxy ...@@ -49,6 +59,9 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxy
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege --let SEARCH_PATTERN= missing required privilege
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
...@@ -59,17 +72,24 @@ REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; ...@@ -59,17 +72,24 @@ REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
--disable_result_log --disable_result_log
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --kill-long-query-type=ALL --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --kill-long-query-type=ALL --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
--let SEARCH_FILE=$log
--let SEARCH_PATTERN= missing required privilege CONNECTION ADMIN --let SEARCH_PATTERN= missing required privilege CONNECTION ADMIN
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
GRANT CONNECTION ADMIN ON *.* TO backup@localhost; GRANT CONNECTION ADMIN ON *.* TO backup@localhost;
--disable_result_log --disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --password=xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --password xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege --let SEARCH_PATTERN= missing required privilege
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
# --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR # --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR
...@@ -79,6 +99,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup ...@@ -79,6 +99,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup
--enable_result_log --enable_result_log
rmdir $targetdir; rmdir $targetdir;
--let SEARCH_FILE=$log
--let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN --let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR --let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
...@@ -91,6 +112,9 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxy ...@@ -91,6 +112,9 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxy
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege --let SEARCH_PATTERN= missing required privilege
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_FILE=$info
--let SEARCH_PATTERN=xyz
--source include/search_pattern_in_file.inc
rmdir $targetdir; rmdir $targetdir;
DROP USER backup@localhost; DROP USER backup@localhost;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment