Commit a07c10f5 authored by Sergei Golubchik's avatar Sergei Golubchik

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
parent 9c74cc4d
......@@ -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)
# 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})
# Put it in /etc/pam.d/mariadb_mtr
auth required pam_mariadb_mtr.so pam_test
account required pam_permit.so
/*
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment