1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-07 04:01:59 +03:00
mariadb/mysql-test/suite/plugins/t/unix_socket.test
Elena Stepanova 41fd4844e8 unix_socket fails in some build environments when $USER variable
appears to be unset, or when it contains 'root' even though the user
does not have real root permissions
2014-02-05 14:25:37 +04:00

73 lines
2.0 KiB
Plaintext

--source include/not_embedded.inc
# If we run this as root, $USER gets authenticated as the `root' user, and we
# get .result differences from CURRENT_USER().
--source include/not_as_root.inc
# The previous check verifies that the user does not have root permissions.
# However in some cases tests are run under a user named 'root',
# even although this user does not have real root permissions.
# This test should be skipped in this case, since it does not expect
# that there are records in mysql.user where user=<username>
if ($USER=="root") {
skip Cannot be run by user named 'root' even if it does not have all privileges;
}
if (!$AUTH_SOCKET_SO) {
skip No auth_socket plugin;
}
if (!$USER) {
skip USER variable is undefined;
}
let $plugindir=`SELECT @@global.plugin_dir`;
eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
--echo #
--echo # with named user
--echo #
--replace_result $USER USER
eval create user $USER identified via unix_socket;
--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--replace_result $USER USER
select user(), current_user(), database();
EOF
--echo #
--echo # name match = ok
--echo #
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--replace_result $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 --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
# restoring mysql.user to the original state.
delete from mysql.user where user='';
uninstall plugin unix_socket;
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt