There is an exmple in Appendix A, "Sample PAM Application" in Pluggable Authentication Module on the FreeBSD site which I cannot get to work.
Can someone spot the problem? Is it a PAM configuration problem? Is it a coding problem?
I am currently signed in as user1 and attempting to su (switch user) to testu who has a password of testu.
Do I need to be signed in as root to run the "su" program?
This is the critical part of the code:
I get a PAM "Authentication Failure".
This is the run:
Thanks for any assistance
Can someone spot the problem? Is it a PAM configuration problem? Is it a coding problem?
I am currently signed in as user1 and attempting to su (switch user) to testu who has a password of testu.
Do I need to be signed in as root to run the "su" program?
This is the critical part of the code:
Code:
/* initialize PAM */
pamc.conv = &misc_conv;
pam_start("su", user, &pamc, &pamh);
/* set some items */
if (strlen(hostname)==0) gethostname(hostname, sizeof(hostname));
if (user==0) getlogin();
tty = ttyname(STDERR_FILENO);
printf("host %s user %s tty %s\n",hostname,user,tty);
if ((pam_err = pam_set_item(pamh, PAM_RHOST, hostname)) != PAM_SUCCESS)
goto pamerr;
if ((pam_err = pam_set_item(pamh, PAM_RUSER, user)) != PAM_SUCCESS)
goto pamerr;
if ((pam_err = pam_set_item(pamh, PAM_TTY, tty)) != PAM_SUCCESS)
goto pamerr;
/* authenticate the applicant */
if ((pam_err = pam_authenticate(pamh, 0)) != PAM_SUCCESS) {
printf("pam_authenticate() failed\n");
fprintf(stderr, "Sorry\n");
fprintf(stderr,"%s\n",pam_strerror(pamh,pam_err));
goto pamerr;
}
This is the run:
Code:
./su testu
host myserver user testu tty /dev/pts/1
Password:
pam_authenticate() failed
Sorry
Authentication failure
Thanks for any assistance