summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-12-30 13:57:03 +0100
committerSergei Golubchik <sergii@pisem.net>2011-12-30 13:57:03 +0100
commitb8b7b4eb6bef26d05257272be02674ae5514ded9 (patch)
tree73045cd67ff7b6f61406afde77235d2b9b563877
parent1417606b1f4c5f8a4c24f6a93a77586f9cf5975c (diff)
downloadmariadb-git-b8b7b4eb6bef26d05257272be02674ae5514ded9.tar.gz
plugin renamed socket_peercred -> unix_socket.
test added.
-rw-r--r--mysql-test/suite/plugins/r/unix_socket.result30
-rw-r--r--mysql-test/suite/plugins/t/unix_socket.test56
-rw-r--r--plugin/auth/auth_socket.c18
3 files changed, 87 insertions, 17 deletions
diff --git a/mysql-test/suite/plugins/r/unix_socket.result b/mysql-test/suite/plugins/r/unix_socket.result
new file mode 100644
index 00000000000..45bf608cc93
--- /dev/null
+++ b/mysql-test/suite/plugins/r/unix_socket.result
@@ -0,0 +1,30 @@
+install plugin unix_socket soname 'auth_socket.so';
+#
+# with named user
+#
+create user USER identified via unix_socket;
+#
+# name match = ok
+#
+select user(), current_user(), database();
+user() current_user() database()
+USER@localhost USER@% test
+#
+# name does not match = failure
+#
+drop user USER;
+#
+# and now with anonymous user
+#
+grant SELECT ON test.* TO '' identified via unix_socket;
+#
+# name match = ok
+#
+select user(), current_user(), database();
+user() current_user() database()
+USER@localhost @% test
+#
+# name does not match = failure
+#
+delete from mysql.user where user='';
+uninstall plugin unix_socket;
diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test
new file mode 100644
index 00000000000..fc2e6c5b3c6
--- /dev/null
+++ b/mysql-test/suite/plugins/t/unix_socket.test
@@ -0,0 +1,56 @@
+--source include/not_embedded.inc
+
+if (!$AUTH_SOCKET_SO) {
+ skip No auth_socket plugin;
+}
+
+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
+
diff --git a/plugin/auth/auth_socket.c b/plugin/auth/auth_socket.c
index cc406dac331..89d24e46f3c 100644
--- a/plugin/auth/auth_socket.c
+++ b/plugin/auth/auth_socket.c
@@ -83,27 +83,11 @@ static struct st_mysql_auth socket_auth_handler=
socket_auth
};
-mysql_declare_plugin(socket_auth)
-{
- MYSQL_AUTHENTICATION_PLUGIN,
- &socket_auth_handler,
- "socket_peercred",
- "Sergei Golubchik",
- "Unix Socket based authentication",
- PLUGIN_LICENSE_GPL,
- NULL,
- NULL,
- 0x0100,
- NULL,
- NULL,
- NULL
-}
-mysql_declare_plugin_end;
maria_declare_plugin(socket_auth)
{
MYSQL_AUTHENTICATION_PLUGIN,
&socket_auth_handler,
- "socket_peercred",
+ "unix_socket",
"Sergei Golubchik",
"Unix Socket based authentication",
PLUGIN_LICENSE_GPL,