| 1 |
--source include/have_unix_socket.inc |
| 2 |
|
| 3 |
--echo # |
| 4 |
--echo # with named user |
| 5 |
--echo # |
| 6 |
|
| 7 |
--let $replace=create user '$USER' |
| 8 |
--let $greplace=grant select on test.* to '$USER' |
| 9 |
--replace_result $replace "create user 'USER'" |
| 10 |
eval create user '$USER' identified via unix_socket; |
| 11 |
--replace_result $greplace "grant select on test.* to 'USER'" |
| 12 |
eval grant select on test.* to '$USER'; |
| 13 |
|
| 14 |
--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 15 |
--let $replace1=$USER@localhost |
| 16 |
--let $replace2=$USER@% |
| 17 |
--replace_result $replace1 "USER@localhost" $replace2 "USER@%" |
| 18 |
select user(), current_user(), database(); |
| 19 |
EOF |
| 20 |
|
| 21 |
--echo # |
| 22 |
--echo # name match = ok |
| 23 |
--echo # |
| 24 |
--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # name does not match = failure |
| 28 |
--echo # |
| 29 |
--error 1 |
| 30 |
--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 31 |
|
| 32 |
--let $replace=drop user '$USER' |
| 33 |
--replace_result $replace "drop user 'USER'" |
| 34 |
eval drop user '$USER'; |
| 35 |
|
| 36 |
--echo # |
| 37 |
--echo # and now with anonymous user |
| 38 |
--echo # |
| 39 |
grant SELECT ON test.* TO '' identified via unix_socket; |
| 40 |
--echo # |
| 41 |
--echo # name match = ok |
| 42 |
--echo # |
| 43 |
--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 44 |
|
| 45 |
--echo # |
| 46 |
--echo # name does not match = failure |
| 47 |
--echo # |
| 48 |
--error 1 |
| 49 |
--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 50 |
|
| 51 |
# restoring mysql.user to the original state. |
| 52 |
delete from mysql.user where user=''; |
| 53 |
FLUSH PRIVILEGES; |
| 54 |
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt |
| 55 |
|
| 56 |
delete from mysql.db; |