Skip to content
Permalink
Browse files

build pam test module as a part of the build

and install in mysql-test/suite/plugins/pam
so that it could be manually copied into /etc if needed
  • Loading branch information...
vuvova committed Jun 30, 2019
1 parent 9c74cc4 commit a07c10f53f155b20495b167e330c90427a6af978
@@ -12,11 +12,16 @@ IF(HAVE_PAM_APPL_H)
ADD_DEFINITIONS(-D_GNU_SOURCE)
MYSQL_ADD_PLUGIN(auth_pam_v1 auth_pam_v1.c LINK_LIBRARIES pam MODULE_ONLY)
MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam dl MODULE_ONLY)
MYSQL_ADD_EXECUTABLE(auth_pam_tool auth_pam_tool.c DESTINATION ${INSTALL_PLUGINDIR}/auth_pam_tool_dir COMPONENT Server)
TARGET_LINK_LIBRARIES(auth_pam_tool pam)
INSTALL(CODE "EXECUTE_PROCESS(
COMMAND chmod u=rwx,g=,o= auth_pam_tool_dir
COMMAND chmod u=rwxs,g=rx,o=rx auth_pam_tool_dir/auth_pam_tool
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR}/)"
COMPONENT Server)
IF (TARGET auth_pam)
MYSQL_ADD_EXECUTABLE(auth_pam_tool auth_pam_tool.c DESTINATION ${INSTALL_PLUGINDIR}/auth_pam_tool_dir COMPONENT Server)
TARGET_LINK_LIBRARIES(auth_pam_tool pam)
INSTALL(CODE "EXECUTE_PROCESS(
COMMAND chmod u=rwx,g=,o= auth_pam_tool_dir
COMMAND chmod u=rwxs,g=rx,o=rx auth_pam_tool_dir/auth_pam_tool
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR}/)"
COMPONENT Server)
ENDIF()
IF(TARGET auth_pam OR TARGET auth_pam_v1)
ADD_SUBDIRECTORY(testing)
ENDIF()
ENDIF(HAVE_PAM_APPL_H)
@@ -0,0 +1,9 @@
# gcc pam_mariadb_mtr.c -shared -lpam -fPIC -o pam_mariadb_mtr.so

ADD_LIBRARY(pam_mariadb_mtr MODULE pam_mariadb_mtr.c)
SET_TARGET_PROPERTIES (pam_mariadb_mtr PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(pam_mariadb_mtr pam)

SET(dest DESTINATION "${INSTALL_MYSQLTESTDIR}/suite/plugins/pam" COMPONENT Test)
INSTALL(TARGETS pam_mariadb_mtr ${dest})
INSTALL(FILES mariadb_mtr.conf RENAME mariadb_mtr ${dest})
@@ -0,0 +1,4 @@
# Put it in /etc/pam.d/mariadb_mtr

auth required pam_mariadb_mtr.so pam_test
account required pam_permit.so
@@ -1,19 +1,11 @@
/*
This code is in the public domain and has no copyright.
Pam module to test pam authentication plugin. Used in pam.test.
Pam module to test pam authentication plugin. Used in pam tests.
Linux only.
Compile as
gcc pam_mariadb_mtr.c -shared -lpam -fPIC -o pam_mariadb_mtr.so
Install as appropriate (for example, in /lib/security/).
Create /etc/pam.d/mariadb_mtr with
=========================================================
auth required pam_mariadb_mtr.so pam_test
account required pam_permit.so
=========================================================
see also mariadb_mtr.conf
*/

#include <stdlib.h>
@@ -59,7 +51,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
if (strcmp(r1, "crash pam module") == 0 && atoi(r2) == 616)
abort();

if (strlen(r1) == atoi(r2) % 100)
if (strlen(r1) == (uint)atoi(r2) % 100)
retval = PAM_SUCCESS;
else
retval = PAM_AUTH_ERR;

0 comments on commit a07c10f

Please sign in to comment.
You can’t perform that action at this time.