I'm currently trying to test a PAM module, this one: http://www.linux-pam.org/Linux-PAM-html/adg-example.html.
There is no indication about where to put the .o
file.
I tried to put it in /lib/security
and /usr/lib/security
but it doesn't work.
I had no error while compiling:
$ gcc -fPIC -c check_user.c
$ ld -x --shared -o check_user.so check_user.o
As indicated, I put those lines in /etc/pam.d/check_user
:
auth required pam_unix.so
account required pam_unix.so
It doesn't seem to work because when I try to log in with another account I don't have the message. What's wrong?
For those who want to create a PAM module, there is a very good example here: https://github.com/beatgammit/simple-pam.
In my case, the functions to call in my PAM module to exec something at login/logout are:
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags,int argc, const char **argv ) {
printf("Connected\n");
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags,int argc, const char **argv ) {
printf("Disconnected\n");
return PAM_SUCCESS;
}
As indicated in the README
, the so
file needs to be put into /lib/security/
.