I compile pam hook based in the interface with this compilation flag's:
gcc -O0 -g -m32 -I/ext -I/inc -MD -MP -c -DARCH=x86 -o my_pam.o my_pam.c
cat /etc/pam.d/sshd
account optional /root/my_pam.so
session optional /root/my_pam.so
auth optional /root/my_pam.so
password optional /root/my_pam.so
The code my_pam.c:
#define _GNU_SOURCE
#define PAM_OK 0
#define PAM_ERROR -1
/*PAM defintion */
#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define PAM_SM_SESSION
#define PAM_SM_PASSWORD
/*PAM includes */
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
#include <security/pam_ext.h>
/* The actual pam functions are merely wrappers around succeed_if */
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return (PAM_SUCCESS);
}
PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh,const int flags,int argc,const char **argv)
{
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
and when i try to login via ssh i can't login and the log file /var/log/auth.log tel's me that error : PAM unable to dlopen /root/my_pam.so wrong ELF class: ELFCLASS32 I guess it is because I am on a 64 bit ubuntu and compiled with 32 bit flag (which is what I want), I did install sudo apt-get install libpam0g-dev:i386 in order to have also the pam library for 32 bit but it seems that pam still looking for it's 64 bit version. How do I fix this and make ubuntu use my 32 bit pam?