Skip to content

Commit

Permalink
try harder to link unix_socket plugin statically
Browse files Browse the repository at this point in the history
fix unix_socket tests to work if unix_socket is a built-in
  • Loading branch information
vuvova committed Feb 21, 2019
1 parent 38bf931 commit 83de75d
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 50 deletions.
6 changes: 3 additions & 3 deletions cmake/build_configurations/mysql_release.cmake
Expand Up @@ -97,20 +97,20 @@ ELSEIF(RPM)
SET(CHECKMODULE /usr/bin/checkmodule CACHE STRING "") SET(CHECKMODULE /usr/bin/checkmodule CACHE STRING "")
SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE STRING "") SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE STRING "")
SET(WITH_LIBARCHIVE ON CACHE STRING "") SET(WITH_LIBARCHIVE ON CACHE STRING "")
SET(PLUGIN_AUTH_SOCKET YES) SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "")
ELSEIF(DEB) ELSEIF(DEB)
SET(WITH_SSL system CACHE STRING "") SET(WITH_SSL system CACHE STRING "")
SET(WITH_ZLIB system CACHE STRING "") SET(WITH_ZLIB system CACHE STRING "")
SET(WITH_LIBWRAP ON) SET(WITH_LIBWRAP ON)
SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON) SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON)
SET(WITH_LIBARCHIVE ON CACHE STRING "") SET(WITH_LIBARCHIVE ON CACHE STRING "")
SET(PLUGIN_AUTH_SOCKET YES) SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "")
ELSE() ELSE()
SET(WITH_SSL bundled CACHE STRING "") SET(WITH_SSL bundled CACHE STRING "")
SET(WITH_ZLIB bundled CACHE STRING "") SET(WITH_ZLIB bundled CACHE STRING "")
SET(WITH_JEMALLOC static CACHE STRING "") SET(WITH_JEMALLOC static CACHE STRING "")
SET(WITH_LIBARCHIVE STATIC CACHE STRING "") SET(WITH_LIBARCHIVE STATIC CACHE STRING "")
SET(PLUGIN_AUTH_SOCKET STATIC) SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "")
ENDIF() ENDIF()


IF(NOT COMPILATION_COMMENT) IF(NOT COMPILATION_COMMENT)
Expand Down
1 change: 0 additions & 1 deletion debian/mariadb-server-10.4.install
Expand Up @@ -40,7 +40,6 @@ usr/lib/mysql/plugin/auth_ed25519.so
usr/lib/mysql/plugin/auth_pam.so usr/lib/mysql/plugin/auth_pam.so
usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool
usr/lib/mysql/plugin/auth_pam_v1.so usr/lib/mysql/plugin/auth_pam_v1.so
usr/lib/mysql/plugin/auth_socket.so
usr/lib/mysql/plugin/disks.so usr/lib/mysql/plugin/disks.so
usr/lib/mysql/plugin/file_key_management.so usr/lib/mysql/plugin/file_key_management.so
usr/lib/mysql/plugin/ha_archive.so usr/lib/mysql/plugin/ha_archive.so
Expand Down
5 changes: 3 additions & 2 deletions mysql-test/include/have_unix_socket.inc
@@ -1,7 +1,8 @@
--source include/not_embedded.inc --source include/not_embedded.inc


if (!$AUTH_SOCKET_SO) { if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'unix_socket' and plugin_status='active'`)
skip No unix_socket plugin; {
--skip Needs unix_socket plugin
} }


if (!$USER) { if (!$USER) {
Expand Down
1 change: 1 addition & 0 deletions mysql-test/include/have_unix_socket.opt
@@ -0,0 +1 @@
--plugin-load-add=$AUTH_SOCKET_SO --loose-enable-unix-socket
6 changes: 0 additions & 6 deletions mysql-test/main/failed_auth_unixsocket.result
@@ -1,13 +1,7 @@
update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket'); update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket');
flush privileges; flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET); connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Plugin 'unix_socket' is not loaded
ERROR HY000: Plugin 'unix_socket' is not loaded
install plugin unix_socket soname 'auth_socket.so';
flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'USER'@'localhost' ERROR 28000: Access denied for user 'USER'@'localhost'
ERROR 28000: Access denied for user 'USER'@'localhost' ERROR 28000: Access denied for user 'USER'@'localhost'
update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin')); update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin'));
flush privileges; flush privileges;
uninstall plugin unix_socket;
18 changes: 1 addition & 17 deletions mysql-test/main/failed_auth_unixsocket.test
Expand Up @@ -11,32 +11,16 @@ flush privileges;
# that matches other parts of the error message. # that matches other parts of the error message.
let $replace=Access denied for user '$USER'; let $replace=Access denied for user '$USER';


--echo connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
--replace_result $replace "Access denied for user 'USER'"
--disable_query_log
--error ER_PLUGIN_IS_NOT_LOADED
connect (fail,localhost,$USER);
--enable_query_log

--replace_result $replace "Access denied for user 'USER'"
--error ER_PLUGIN_IS_NOT_LOADED
change_user $USER;

eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
flush privileges;

--echo connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET); --echo connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
--replace_result $replace "Access denied for user 'USER'" --replace_result $replace "Access denied for user 'USER'"
--disable_query_log --disable_query_log
--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR --error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
connect (fail,localhost,$USER); connect (fail,localhost,$USER);
--enable_query_log --enable_query_log


--replace_result $replace "Access denied for user 'USER'" --replace_result $replace "Access denied for user 'USER'"
--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR --error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
change_user $USER; change_user $USER;


update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin')); update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin'));
flush privileges; flush privileges;
uninstall plugin unix_socket;

2 changes: 0 additions & 2 deletions mysql-test/suite/plugins/r/multiauth.result
@@ -1,4 +1,3 @@
install soname 'auth_socket';
install soname 'auth_ed25519'; install soname 'auth_ed25519';
create user USER identified via unix_socket OR mysql_native_password as password("GOOD"); create user USER identified via unix_socket OR mysql_native_password as password("GOOD");
create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good");
Expand Down Expand Up @@ -190,5 +189,4 @@ select user(), current_user(), database();
user() current_user() database() user() current_user() database()
mysqltest1@localhost mysqltest1@% test mysqltest1@localhost mysqltest1@% test
drop user mysqltest1; drop user mysqltest1;
uninstall soname 'auth_socket';
uninstall soname 'auth_ed25519'; uninstall soname 'auth_ed25519';
2 changes: 0 additions & 2 deletions mysql-test/suite/plugins/r/unix_socket.result
@@ -1,4 +1,3 @@
install plugin unix_socket soname 'auth_socket.so';
# #
# with named user # with named user
# #
Expand Down Expand Up @@ -28,4 +27,3 @@ USER@localhost @% test
# #
delete from mysql.user where user=''; delete from mysql.user where user='';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
uninstall plugin unix_socket;
2 changes: 0 additions & 2 deletions mysql-test/suite/plugins/t/multiauth.test
Expand Up @@ -10,7 +10,6 @@ if (!$AUTH_ED25519_SO) {
} }


--let $plugindir=`SELECT @@global.plugin_dir` --let $plugindir=`SELECT @@global.plugin_dir`
install soname 'auth_socket';
install soname 'auth_ed25519'; install soname 'auth_ed25519';


--let $try_auth=$MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/peercred_test.txt 2>&1 --let $try_auth=$MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/peercred_test.txt 2>&1
Expand Down Expand Up @@ -192,6 +191,5 @@ show create user mysqltest1;
--exec $try_auth -u mysqltest1 -pworks --plugin-dir=$plugindir/no --exec $try_auth -u mysqltest1 -pworks --plugin-dir=$plugindir/no
drop user mysqltest1; drop user mysqltest1;


uninstall soname 'auth_socket';
uninstall soname 'auth_ed25519'; uninstall soname 'auth_ed25519';
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt --remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
17 changes: 4 additions & 13 deletions mysql-test/suite/plugins/t/unix_socket.test
@@ -1,13 +1,5 @@
--source include/have_unix_socket.inc --source include/have_unix_socket.inc


if (!$USER) {
skip USER variable is undefined;
}

let $plugindir=`SELECT @@global.plugin_dir`;

eval install plugin unix_socket soname '$AUTH_SOCKET_SO';

--echo # --echo #
--echo # with named user --echo # with named user
--echo # --echo #
Expand All @@ -26,13 +18,13 @@ EOF
--echo # --echo #
--echo # name match = ok --echo # name match = ok
--echo # --echo #
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt --exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt


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


--let $replace=drop user $USER --let $replace=drop user $USER
--replace_result $replace "drop user USER" --replace_result $replace "drop user USER"
Expand All @@ -45,16 +37,15 @@ grant SELECT ON test.* TO '' identified via unix_socket;
--echo # --echo #
--echo # name match = ok --echo # name match = ok
--echo # --echo #
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt --exec $MYSQL_TEST -u $USER < $MYSQLTEST_VARDIR/tmp/peercred_test.txt


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


# restoring mysql.user to the original state. # restoring mysql.user to the original state.
delete from mysql.user where user=''; delete from mysql.user where user='';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
uninstall plugin unix_socket;
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt --remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
2 changes: 1 addition & 1 deletion plugin/auth_socket/CMakeLists.txt
Expand Up @@ -65,5 +65,5 @@ ENDIF()
ENDIF() ENDIF()


IF(ok) IF(ok)
MYSQL_ADD_PLUGIN(auth_socket auth_socket.c) MYSQL_ADD_PLUGIN(auth_socket auth_socket.c DEFAULT)
ENDIF() ENDIF()
2 changes: 1 addition & 1 deletion scripts/mysql_install_db.sh
Expand Up @@ -345,7 +345,7 @@ then
cannot_find_file fill_help_tables.sql @pkgdata_locations@ cannot_find_file fill_help_tables.sql @pkgdata_locations@
exit 1 exit 1
fi fi
plugindir=`find_in_dirs --dir auth_socket.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin` plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin`

This comment has been minimized.

Copy link
@midenok

midenok Mar 23, 2019

Contributor

@vuvova If no auth_pam.so compiled the script fails.

pamtooldir=$plugindir pamtooldir=$plugindir
# relative from where the script was run for a relocatable install # relative from where the script was run for a relocatable install
elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld" elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld"
Expand Down

0 comments on commit 83de75d

Please sign in to comment.