Debian Codegraph @

mysql-test/suite/plugins/r/unix_socket_osuser_match_auth_string.result

raw
1 ########################################################################
2 # Test for case:
3 # - create user A identified via unix_socket as 'B' or unix_socket as 'C';
4 # - connect as database user A using unix user of B
5 # Expected result:
6 # - connection succeed
7 ########################################################################
8 create user 'DB_USER1' identified via unix_socket as 'OS_USER' or unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name';
9 grant select on test.* to 'DB_USER1';
10 #
11 # Auth succeed with OS user matches the first authentication string.
12 # @@external_user is set to OS_USER name.
13 #
14 select user(), current_user(), database();
15 user() current_user() database()
16 DB_USER1@localhost DB_USER1@% test
17 select @@external_user;
18 @@external_user
19 OS_USER
20 select host, user, json_value(priv, '$.authentication_string') as authentication_string,
21 json_value(priv, '$.auth_or[0].authentication_string') as optional_authentication_string from mysql.global_priv where user='DB_USER1';
22 host user authentication_string optional_authentication_string
23 % DB_USER1 -Cannot-Match-Any-Legal-Unix-User-Name OS_USER
24
25 ########################################################################
26 # Test for case:
27 # - create user A identified via unix_socket as 'B' or unix_socket as 'C';
28 # - connect as database user A using unix user of C
29 # Expected result:
30 # - connection succeed
31 ########################################################################
32 create user 'DB_USER2' identified via unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name' or unix_socket as 'OS_USER';
33 grant select on test.* to 'DB_USER2';
34 #
35 # Auth succeed with OS user matches the optional authentication string.
36 # @@external_user is set to OS_USER name.
37 #
38 select user(), current_user(), database();
39 user() current_user() database()
40 DB_USER2@localhost DB_USER2@% test
41 select @@external_user;
42 @@external_user
43 OS_USER
44 select host, user, json_value(priv, '$.authentication_string') as authentication_string,
45 json_value(priv, '$.auth_or[0].authentication_string') as optional_authentication_string from mysql.global_priv where user='DB_USER1';
46 host user authentication_string optional_authentication_string
47 % DB_USER1 -Cannot-Match-Any-Legal-Unix-User-Name OS_USER
48
49 ########################################################################
50 # Test for case:
51 # - create user A identified via unix_socket as 'B';
52 # - connect as database user A using unix user of D
53 # Expected result:
54 # - connection is refused
55 ########################################################################
56 create user 'DB_USER3' identified via unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name';
57 grant select on test.* to 'DB_USER3';
58 #
59 # Auth fail with OS user that does not match the authentication string.
60 #
61 #
62 ########################################################################
63 # Test for case:
64 # - create user A identified via unix_socket as 'B' or unix_socket as 'C';
65 # - connect as database user A using unix user of D
66 # Expected result:
67 # - connection is refused
68 ########################################################################
69 create user 'DB_USER4' identified via unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-1'
70 or unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-2';
71 grant select on test.* to 'DB_USER4';
72 #
73 # Auth fail with OS user that does not match the authentication string.
74 #
75 select host, user, json_value(priv, '$.authentication_string') as authentication_string,
76 json_value(priv, '$.auth_or[0].authentication_string') as optional_authentication_string from mysql.global_priv where user='DB_USER1';
77 host user authentication_string optional_authentication_string
78 % DB_USER1 -Cannot-Match-Any-Legal-Unix-User-Name OS_USER
79 ########################################################################
80 # Test for case:
81 # - create user A identified via unix_socket as 'B' or unix_socket as 'C' or unix_socket as 'D' or unix_socket as 'E' or unix_socket as 'F';
82 # - connect as database user A using unix user of 'D'
83 # Expected result:
84 # - connection succeed
85 ########################################################################
86 create user 'DB_USER5' identified via unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-B'
87 or unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-C'
88 or unix_socket as 'OS_USER'
89 or unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-E'
90 or unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name-F';
91 grant select on test.* to 'DB_USER5';
92 #
93 # Auth succeed with OS user matches the first authentication string.
94 # @@external_user is set to OS_USER name.
95 #
96 select user(), current_user(), database();
97 user() current_user() database()
98 DB_USER5@localhost DB_USER5@% test
99 select @@external_user;
100 @@external_user
101 OS_USER
102 select host, user, json_value(priv, '$.authentication_string') as authentication_string,
103 json_value(priv, '$.auth_or[0].authentication_string') as optional_authentication_string_0,
104 json_value(priv, '$.auth_or[1].authentication_string') as optional_authentication_string_1,
105 json_value(priv, '$.auth_or[2].authentication_string') as optional_authentication_string_2,
106 json_value(priv, '$.auth_or[3].authentication_string') as optional_authentication_string_3
107 from mysql.global_priv where user='DB_USER5';
108 host user authentication_string optional_authentication_string_0 optional_authentication_string_1 optional_authentication_string_2 optional_authentication_string_3
109 % DB_USER5 -Cannot-Match-Any-Legal-Unix-User-Name-F -Cannot-Match-Any-Legal-Unix-User-Name-B -Cannot-Match-Any-Legal-Unix-User-Name-C OS_USER -Cannot-Match-Any-Legal-Unix-User-Name-E
110
111 ########################################################################
112 # Test for case:
113 # - create user A identified via unix_socket as 'B';
114 # - connect as database user A using unix user of A
115 # Expected result:
116 # - connection is rejected
117 ########################################################################
118 #
119 # Create DB user different with the OS user name, but using OS user name as the authentication string.
120 #
121 create user 'OS_USER' identified via unix_socket as '-Cannot-Match-Any-Legal-Unix-User-Name';
122 grant select on test.* to 'OS_USER';
123 #
124 # Auth fail with OS user that does not match the authentication string.
125 #
126
127 ########################################################################
128 # Removing the test user.
129 ########################################################################
130 drop user 'DB_USER1';
131 drop user 'DB_USER2';
132 drop user 'DB_USER3';
133 drop user 'DB_USER4';
134 drop user 'DB_USER5';
135 drop user 'OS_USER';
136 FLUSH PRIVILEGES;
137 ########################################################################
138 # Removing the test file.
139 ########################################################################