January 2nd, 2005, 11:22 PM
PAM aware application
Anyone have examples of making an application "PAM aware"? I need to modify some login code to use the PAM modules on Solaris and hope there is a simple example out there. I don't need to write a module, as I will use the standard one(s).
I found this simple code here...
but it is for Linux and doesn't pass a password.
THanks for any help, I'm a Java programmer and have some difficulty with C. :confused:
January 3rd, 2005, 07:59 AM
This site might be helpful, but you may have already known that. I also remember printing out a few of the man pages.
Here's some old test source code from when I was messing around with it a few years ago (on Solaris). It just takes the user name and password as command line parameters and authenticates via PAM.
Hope this helps.
int main (int argc, char *argv)
pam_handle_t *pamHandle = NULL;
if (argc < 3)
int pamResult = pam_start (argv, NULL, NULL, &pamHandle);
if (pamResult != PAM_SUCCESS)
std::cerr << "pam_start error: "
<< pam_strerror (NULL, pamResult) << std::endl;
pam_set_item (pamHandle, PAM_USER, argv);
pam_set_item (pamHandle, PAM_AUTHTOK, argv);
pamResult = pam_authenticate (pamHandle, 0);
std::cerr << "Authentication result: "
<< pam_strerror (pamHandle, pamResult) << std::endl;
pam_end (pamHandle, pamResult);
January 3rd, 2005, 09:29 AM
THanks, this is what I was looking for. :)