Skip to content

Commit 034abab

Browse files
committed
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.
1 parent 29c185b commit 034abab

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6413,7 +6413,7 @@ static bool check_all_privileges()
64136413
if (opt_galera_info || opt_slave_info
64146414
|| opt_safe_slave_backup) {
64156415
check_result |= check_privilege(granted_privileges,
6416-
"REPLICA MONITOR", "*", "*",
6416+
"SLAVE MONITOR", "*", "*",
64176417
PRIVILEGE_WARNING);
64186418
}
64196419

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
CREATE user backup@localhost IDENTIFIED BY 'xyz';
2+
NOT FOUND /missing required privilege/ in backup.log
23
FOUND 1 /missing required privilege RELOAD/ in backup.log
34
FOUND 1 /missing required privilege PROCESS/ in backup.log
45
FOUND 1 /GRANT USAGE ON/ in backup.log
56
GRANT RELOAD, PROCESS on *.* to backup@localhost;
6-
FOUND 1 /missing required privilege REPLICA MONITOR/ in backup.log
7+
NOT FOUND /missing required privilege/ in backup.log
8+
FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log
79
GRANT REPLICA MONITOR ON *.* TO backup@localhost;
10+
NOT FOUND /missing required privilege/ in backup.log
811
REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
912
FOUND 1 /missing required privilege CONNECTION ADMIN/ in backup.log
1013
GRANT CONNECTION ADMIN ON *.* TO backup@localhost;
14+
NOT FOUND /missing required privilege/ in backup.log
1115
FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log
12-
FOUND 1 /missing required privilege REPLICA MONITOR/ in backup.log
16+
FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log
1317
GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost;
1418
GRANT REPLICA MONITOR ON *.* TO backup@localhost;
19+
NOT FOUND /missing required privilege/ in backup.log
1520
DROP USER backup@localhost;

mysql-test/suite/mariabackup/backup_grants.test

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
22
CREATE user backup@localhost IDENTIFIED BY 'xyz';
33

4+
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log;
45
# backup possible for unprivileges user, with --no-lock
56
--disable_result_log
6-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir;
7+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
78
--enable_result_log
9+
10+
--let SEARCH_PATTERN= missing required privilege
11+
--source include/search_pattern_in_file.inc
812
rmdir $targetdir;
913

1014
# backup fails without --no-lock, because of FTWRL
@@ -13,7 +17,6 @@ error 1;
1317
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
1418
--enable_result_log
1519

16-
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log;
1720
--let SEARCH_PATTERN= missing required privilege RELOAD
1821
--source include/search_pattern_in_file.inc
1922
--let SEARCH_PATTERN= missing required privilege PROCESS
@@ -23,25 +26,29 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log;
2326
# backup succeeds with RELOAD privilege
2427
GRANT RELOAD, PROCESS on *.* to backup@localhost;
2528
--disable_result_log
26-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir;
29+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
2730
--enable_result_log
31+
--let SEARCH_PATTERN= missing required privilege
32+
--source include/search_pattern_in_file.inc
2833
rmdir $targetdir;
2934

3035
# MDEV-23607 Warning: missing required privilege REPLICATION CLIENT
31-
# --slave-info and galera info require REPLICA MONITOR
36+
# --slave-info and --galera-info require REPLICA MONITOR
3237
--disable_result_log
3338
error 1;
3439
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;
3540
--enable_result_log
3641
rmdir $targetdir;
3742

38-
--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR
43+
--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
3944
--source include/search_pattern_in_file.inc
4045

4146
GRANT REPLICA MONITOR ON *.* TO backup@localhost;
4247
--disable_result_log
43-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir;
48+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
4449
--enable_result_log
50+
--let SEARCH_PATTERN= missing required privilege
51+
--source include/search_pattern_in_file.inc
4552
rmdir $targetdir;
4653
REVOKE REPLICA MONITOR ON *.* FROM backup@localhost;
4754

@@ -59,8 +66,10 @@ rmdir $targetdir;
5966

6067
GRANT CONNECTION ADMIN ON *.* TO backup@localhost;
6168
--disable_result_log
62-
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;
69+
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;
6370
--enable_result_log
71+
--let SEARCH_PATTERN= missing required privilege
72+
--source include/search_pattern_in_file.inc
6473
rmdir $targetdir;
6574

6675
# --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR
@@ -72,14 +81,16 @@ rmdir $targetdir;
7281

7382
--let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN
7483
--source include/search_pattern_in_file.inc
75-
--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR
84+
--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR
7685
--source include/search_pattern_in_file.inc
7786

7887
GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost;
7988
GRANT REPLICA MONITOR ON *.* TO backup@localhost;
8089
--disable_result_log
81-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir;
90+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1;
8291
--enable_result_log
92+
--let SEARCH_PATTERN= missing required privilege
93+
--source include/search_pattern_in_file.inc
8394
rmdir $targetdir;
8495

8596
DROP USER backup@localhost;

0 commit comments

Comments
 (0)