Commit 034ababa authored by Daniel Black's avatar Daniel Black

MDEV-34053 mariadbbackup privilege REPLICA MONITOR issue

MariaDB-backup needs to check for SLAVE MONITOR as that is
what is returned by SHOW GRANTS.

Update test to ensure that warnings about missing privileges
do not occur when the backup is successful.

Reviewer: Andrew Hutchings
Thanks Eugene for reporting the issue.
parent 29c185bd
...@@ -6413,7 +6413,7 @@ static bool check_all_privileges() ...@@ -6413,7 +6413,7 @@ static bool check_all_privileges()
if (opt_galera_info || opt_slave_info if (opt_galera_info || opt_slave_info
|| opt_safe_slave_backup) { || opt_safe_slave_backup) {
check_result |= check_privilege(granted_privileges, check_result |= check_privilege(granted_privileges,
"REPLICA MONITOR", "*", "*", "SLAVE MONITOR", "*", "*",
PRIVILEGE_WARNING); PRIVILEGE_WARNING);
} }
......
CREATE user backup@localhost IDENTIFIED BY 'xyz'; CREATE user backup@localhost IDENTIFIED BY 'xyz';
NOT FOUND /missing required privilege/ in backup.log
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;
FOUND 1 /missing required privilege REPLICA MONITOR/ in backup.log NOT FOUND /missing required privilege/ 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
REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
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
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 REPLICA 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
DROP USER backup@localhost; DROP USER backup@localhost;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
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; 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_PATTERN= missing required privilege
--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
...@@ -13,7 +17,6 @@ error 1; ...@@ -13,7 +17,6 @@ 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=$MYSQLTEST_VARDIR/tmp/backup.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
...@@ -23,25 +26,29 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; ...@@ -23,25 +26,29 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log;
# backup succeeds with RELOAD privilege # backup succeeds with RELOAD privilege
GRANT RELOAD, PROCESS on *.* to backup@localhost; GRANT RELOAD, PROCESS on *.* to backup@localhost;
--disable_result_log --disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege
--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_PATTERN= missing required privilege REPLICA MONITOR --let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
GRANT REPLICA MONITOR ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost;
--disable_result_log --disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege
--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,8 +66,10 @@ rmdir $targetdir; ...@@ -59,8 +66,10 @@ rmdir $targetdir;
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 --user=backup --password=xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; 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
--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
...@@ -72,14 +81,16 @@ rmdir $targetdir; ...@@ -72,14 +81,16 @@ rmdir $targetdir;
--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 REPLICA MONITOR --let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
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;
--disable_result_log --disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
--enable_result_log --enable_result_log
--let SEARCH_PATTERN= missing required privilege
--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