summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/plugins/t/unix_socket.test
blob: 892b6f75161975a478f314048cd4feea470c55bc (plain)
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
--source include/have_unix_socket.inc

--echo #
--echo # with named user
--echo #

--let $replace=create user '$USER'
--let $greplace=grant select on test.* to '$USER'
--replace_result $replace "create user 'USER'"
eval create user '$USER' identified via unix_socket;
--replace_result $greplace "grant select on test.* to 'USER'"
eval grant select on test.* to '$USER';

--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--let $replace1=$USER@localhost
--let $replace2=$USER@%
--replace_result $replace1 "USER@localhost" $replace2 "USER@%"
select user(), current_user(), database();
EOF

--echo #
--echo # name match = ok
--echo #
--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt

--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt

--let $replace=drop user '$USER'
--replace_result $replace "drop user 'USER'"
eval drop user '$USER';

--echo #
--echo # and now with anonymous user
--echo #
grant SELECT ON test.* TO '' identified via unix_socket;
--echo #
--echo # name match = ok
--echo #
--exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt

--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar < $MYSQLTEST_VARDIR/tmp/peercred_test.txt

# restoring mysql.user to the original state.
delete from mysql.user where user='';
FLUSH PRIVILEGES;
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt

delete from mysql.db;