| 1 |
--source include/not_ubsan.inc |
| 2 |
|
| 3 |
let $REGEX_VERSION_ID=/$mysql_get_server_version/VERSION_ID/; |
| 4 |
let $REGEX_PASSWORD_LAST_CHANGED=/password_last_changed": [0-9]*/password_last_changed": #/; |
| 5 |
let $REGEX_GLOBAL_PRIV=$REGEX_PASSWORD_LAST_CHANGED $REGEX_VERSION_ID; |
| 6 |
|
| 7 |
# |
| 8 |
# MDEV-11340 Allow multiple alternative authentication methods for the same user |
| 9 |
# |
| 10 |
--source include/have_unix_socket.inc |
| 11 |
if (`SELECT '$USER' = 'mysqltest1'`) { |
| 12 |
skip USER is mysqltest1; |
| 13 |
} |
| 14 |
if (!$AUTH_ED25519_SO) { |
| 15 |
skip No auth_ed25519 plugin; |
| 16 |
} |
| 17 |
|
| 18 |
--let $plugindir=`SELECT @@global.plugin_dir` |
| 19 |
install soname 'auth_ed25519'; |
| 20 |
|
| 21 |
--let $try_auth=$MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/peercred_test.txt 2>&1 |
| 22 |
|
| 23 |
--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 24 |
--let $replace1=$USER@localhost |
| 25 |
--let $replace2=$USER@% |
| 26 |
--replace_result $replace1 "USER@localhost" $replace2 "USER@%" |
| 27 |
select user(), current_user(), database(); |
| 28 |
EOF |
| 29 |
|
| 30 |
--let $creplace=create user '$USER' |
| 31 |
--let $greplace=grant select on test.* to '$USER' |
| 32 |
--let $dreplace=drop user '$USER' |
| 33 |
|
| 34 |
# |
| 35 |
# socket,password |
| 36 |
# |
| 37 |
--replace_result $creplace "create user 'USER'" |
| 38 |
eval $creplace identified via unix_socket OR mysql_native_password as password("GOOD"); |
| 39 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 40 |
eval $greplace ; |
| 41 |
create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); |
| 42 |
grant select on test.* to mysqltest1; |
| 43 |
show create user mysqltest1; |
| 44 |
--echo # name match = ok |
| 45 |
--exec $try_auth -u $USER |
| 46 |
--echo # name does not match, password good = ok |
| 47 |
--exec $try_auth -u mysqltest1 -pgood |
| 48 |
--echo # name does not match, password bad = failure |
| 49 |
--error 1 |
| 50 |
--exec $try_auth -u mysqltest1 -pbad |
| 51 |
--replace_result $dreplace "drop user 'USER'" |
| 52 |
eval $dreplace, mysqltest1; |
| 53 |
|
| 54 |
# |
| 55 |
# password,socket |
| 56 |
# |
| 57 |
--replace_result $creplace "create user 'USER'" |
| 58 |
eval $creplace identified via mysql_native_password as password("GOOD") OR unix_socket; |
| 59 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 60 |
eval $greplace ; |
| 61 |
create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; |
| 62 |
grant select on test.* to mysqltest1; |
| 63 |
show create user mysqltest1; |
| 64 |
--echo # name match = ok |
| 65 |
--exec $try_auth -u $USER |
| 66 |
--echo # name does not match, password good = ok |
| 67 |
--exec $try_auth -u mysqltest1 -pgood |
| 68 |
--echo # name does not match, password bad = failure |
| 69 |
--error 1 |
| 70 |
--exec $try_auth -u mysqltest1 -pbad |
| 71 |
--replace_result $dreplace "drop user 'USER'" |
| 72 |
eval $dreplace, mysqltest1; |
| 73 |
|
| 74 |
# |
| 75 |
# socket,ed25519 |
| 76 |
# |
| 77 |
--replace_result $creplace "create user 'USER'" |
| 78 |
eval $creplace identified via unix_socket OR ed25519 as password("GOOD"); |
| 79 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 80 |
eval $greplace ; |
| 81 |
create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); |
| 82 |
grant select on test.* to mysqltest1; |
| 83 |
show create user mysqltest1; |
| 84 |
--echo # name match = ok |
| 85 |
--exec $try_auth -u $USER |
| 86 |
--echo # name does not match, password good = ok |
| 87 |
--exec $try_auth -u mysqltest1 -pgood |
| 88 |
--echo # name does not match, password bad = failure |
| 89 |
--error 1 |
| 90 |
--exec $try_auth -u mysqltest1 -pbad |
| 91 |
--replace_result $dreplace "drop user 'USER'" |
| 92 |
eval $dreplace, mysqltest1; |
| 93 |
|
| 94 |
# |
| 95 |
# ed25519,socket |
| 96 |
# |
| 97 |
--replace_result $creplace "create user 'USER'" |
| 98 |
eval $creplace identified via ed25519 as password("GOOD") OR unix_socket; |
| 99 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 100 |
eval $greplace ; |
| 101 |
create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; |
| 102 |
grant select on test.* to mysqltest1; |
| 103 |
show create user mysqltest1; |
| 104 |
--echo # name match = ok |
| 105 |
--exec $try_auth -u $USER |
| 106 |
--echo # name does not match, password good = ok |
| 107 |
--exec $try_auth -u mysqltest1 -pgood |
| 108 |
--echo # name does not match, password bad = failure |
| 109 |
--error 1 |
| 110 |
--exec $try_auth -u mysqltest1 -pbad |
| 111 |
--replace_result $dreplace "drop user 'USER'" |
| 112 |
eval $dreplace, mysqltest1; |
| 113 |
|
| 114 |
# |
| 115 |
# ed25519,socket,password |
| 116 |
# |
| 117 |
--replace_result $creplace "create user 'USER'" |
| 118 |
eval $creplace identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); |
| 119 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 120 |
eval $greplace ; |
| 121 |
create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); |
| 122 |
grant select on test.* to mysqltest1; |
| 123 |
show create user mysqltest1; |
| 124 |
--echo # name match = ok |
| 125 |
--exec $try_auth -u $USER |
| 126 |
--echo # name does not match, password good = ok |
| 127 |
--exec $try_auth -u mysqltest1 -pgood |
| 128 |
--echo # name does not match, second password works = ok |
| 129 |
--exec $try_auth -u mysqltest1 -pworks |
| 130 |
--echo # name does not match, password bad = failure |
| 131 |
--error 1 |
| 132 |
--exec $try_auth -u mysqltest1 -pbad |
| 133 |
--replace_result $dreplace "drop user 'USER'" |
| 134 |
eval $dreplace, mysqltest1; |
| 135 |
|
| 136 |
# |
| 137 |
# password,password |
| 138 |
# |
| 139 |
create user mysqltest1 identified via mysql_native_password as password("good") OR mysql_native_password as password("works"); |
| 140 |
grant select on test.* to mysqltest1; |
| 141 |
show create user mysqltest1; |
| 142 |
--echo # password good = ok |
| 143 |
--exec $try_auth -u mysqltest1 -pgood |
| 144 |
--echo # second password works = ok |
| 145 |
--exec $try_auth -u mysqltest1 -pworks |
| 146 |
--echo # password bad = failure |
| 147 |
--error 1 |
| 148 |
--exec $try_auth -u mysqltest1 -pbad |
| 149 |
drop user mysqltest1; |
| 150 |
|
| 151 |
# |
| 152 |
# show grants, flush privileges, set password, alter user |
| 153 |
# |
| 154 |
create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); |
| 155 |
show grants for mysqltest1; |
| 156 |
--replace_regex $REGEX_GLOBAL_PRIV |
| 157 |
select json_detailed(priv) from mysql.global_priv where user='mysqltest1'; |
| 158 |
select password,plugin,authentication_string from mysql.user where user='mysqltest1'; |
| 159 |
flush privileges; |
| 160 |
show create user mysqltest1; |
| 161 |
set password for mysqltest1 = password('foobar'); |
| 162 |
show create user mysqltest1; |
| 163 |
alter user mysqltest1 identified via unix_socket OR mysql_native_password as password("some"); |
| 164 |
show create user mysqltest1; |
| 165 |
--error ER_SET_PASSWORD_AUTH_PLUGIN |
| 166 |
set password for mysqltest1 = password('foobar'); |
| 167 |
show create user mysqltest1; |
| 168 |
alter user mysqltest1 identified via unix_socket; |
| 169 |
--error ER_SET_PASSWORD_AUTH_PLUGIN |
| 170 |
set password for mysqltest1 = password('bla'); |
| 171 |
alter user mysqltest1 identified via mysql_native_password as password("some") or unix_socket; |
| 172 |
show create user mysqltest1; |
| 173 |
drop user mysqltest1; |
| 174 |
|
| 175 |
--source include/switch_to_mysql_user.inc |
| 176 |
--replace_regex /\d{6}/XX.YY.ZZ/ |
| 177 |
--error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE |
| 178 |
create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); |
| 179 |
--source include/switch_to_mysql_global_priv.inc |
| 180 |
|
| 181 |
# |
| 182 |
# invalid password,socket |
| 183 |
# |
| 184 |
--replace_result $creplace "create user 'USER'" |
| 185 |
eval $creplace identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; |
| 186 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 187 |
eval $greplace ; |
| 188 |
create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; |
| 189 |
grant select on test.* to mysqltest1; |
| 190 |
update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); |
| 191 |
flush privileges; |
| 192 |
show create user mysqltest1; |
| 193 |
--echo # name match = ok |
| 194 |
--exec $try_auth -u $USER |
| 195 |
--echo # name does not match = failure |
| 196 |
--error 1 |
| 197 |
--exec $try_auth -u mysqltest1 |
| 198 |
--echo # SET PASSWORD helps |
| 199 |
set password for mysqltest1 = password('bla'); |
| 200 |
--exec $try_auth -u mysqltest1 -pbla |
| 201 |
--replace_result $dreplace "drop user 'USER'" |
| 202 |
eval $dreplace, mysqltest1; |
| 203 |
|
| 204 |
# |
| 205 |
# missing client-side plugin |
| 206 |
# |
| 207 |
create user mysqltest1 identified via ed25519 as password("good"); |
| 208 |
grant select on test.* to mysqltest1; |
| 209 |
show create user mysqltest1; |
| 210 |
--echo # no plugin = failure |
| 211 |
# covers Linux (1st re), FreeBSD (2nd), AIX (3rd and 4th) |
| 212 |
--replace_regex /loaded: .*client_ed25519.so: cannot open shared object file: No such file or directory/loaded: no such file/ /loaded: Cannot open.*client_ed25519.so./loaded: no such file/ /loaded: .*Could not load module.*client_ed25519.so.\n/loaded: no such file/ /System error: No such file or directory// |
| 213 |
--error 1 |
| 214 |
--exec $try_auth -u mysqltest1 -pgood --plugin-dir=$plugindir/no |
| 215 |
alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); |
| 216 |
show create user mysqltest1; |
| 217 |
--echo # no plugin = failure |
| 218 |
--error 1 |
| 219 |
--exec $try_auth -u mysqltest1 -pgood --plugin-dir=$plugindir/no |
| 220 |
--echo # no plugin, second password works = ok |
| 221 |
--exec $try_auth -u mysqltest1 -pworks --plugin-dir=$plugindir/no |
| 222 |
drop user mysqltest1; |
| 223 |
|
| 224 |
uninstall soname 'auth_ed25519'; |
| 225 |
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 226 |
|
| 227 |
# |
| 228 |
# MDEV-21928 ALTER USER doesn't remove excess authentication plugins from mysql.global_priv |
| 229 |
# |
| 230 |
create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; |
| 231 |
show create user mysqltest1; |
| 232 |
alter user mysqltest1 identified via mysql_native_password as password("better"); |
| 233 |
show create user mysqltest1; |
| 234 |
flush privileges; |
| 235 |
show create user mysqltest1; |
| 236 |
drop user mysqltest1; |