File: set_role-9614.result

package info (click to toggle)
mariadb-10.0 10.0.32-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 476,064 kB
  • sloc: cpp: 1,400,131; ansic: 832,140; perl: 54,391; sh: 41,304; pascal: 32,365; yacc: 14,921; xml: 5,257; sql: 4,667; cs: 4,647; makefile: 4,555; ruby: 4,465; python: 2,292; lex: 1,427; java: 941; asm: 295; awk: 54; php: 22; sed: 16
file content (99 lines) | stat: -rw-r--r-- 2,224 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# MDEV-9614 Roles and Users Longer than 6 characters
#
# This test case checks the edge case presented in the MDEV. The
# real issue is actually apparent when the username is longer than the
# rolename.
#
# We need a separate database not including test or test_% names. Due to
# default privileges given on these databases.
#
DROP DATABASE IF EXISTS `bug_db`;
Warnings:
Note	1008	Can't drop database 'bug_db'; database doesn't exist
#
# The first user did not show the bug as john's length is smaller
# than client. The bug is apparent most of the time for usertestjohn.
#
CREATE USER `john`@`%`;
CREATE USER `usertestjohn`@`%`;
CREATE ROLE `client`;
#
# Setup the required tables.
#
CREATE DATABASE `bug_db`;
CREATE TABLE `bug_db`.`t0`(`c0` INT);
#
# Setup select privileges only on the role. Setting the role should give
# select access to bug_db.t0.
#
GRANT SELECT ON `bug_db`.`t0` TO `client`;
GRANT `client` TO `john`@`%`;
GRANT `client` TO `usertestjohn`@`%`;
#
# Check to see grants are set.
#
SHOW GRANTS FOR `john`@`%`;
Grants for john@%
GRANT client TO 'john'@'%'
GRANT USAGE ON *.* TO 'john'@'%'
SHOW GRANTS FOR `usertestjohn`@`%`;
Grants for usertestjohn@%
GRANT client TO 'usertestjohn'@'%'
GRANT USAGE ON *.* TO 'usertestjohn'@'%'
SHOW GRANTS FOR `client`;
Grants for client
GRANT USAGE ON *.* TO 'client'
GRANT SELECT ON `bug_db`.`t0` TO 'client'
show databases;
Database
bug_db
information_schema
mtr
mysql
performance_schema
test
#
# Try using the database as john.
#
connect  john, localhost, john,,information_schema;
show databases;
Database
information_schema
test
set role client;
show databases;
Database
bug_db
information_schema
test
use bug_db;
#
# Try using the database as usertestjohn.
#
connect  usertestjohn, localhost, usertestjohn,,information_schema;
show databases;
Database
information_schema
test
set role client;
show databases;
Database
bug_db
information_schema
test
show grants;
Grants for usertestjohn@%
GRANT client TO 'usertestjohn'@'%'
GRANT USAGE ON *.* TO 'usertestjohn'@'%'
GRANT USAGE ON *.* TO 'client'
GRANT SELECT ON `bug_db`.`t0` TO 'client'
use bug_db;
#
# Cleanup
#
connection default;
drop user john;
drop user usertestjohn;
drop role client;
drop database bug_db;