need help on PAM module on Solaris

  • Follow


Has anybody worked with Pluggable Authentication Module (PAM) on Solaris?
The problem we are trying to solve is to verify that a given username and
password are valid credentials.

I wrote the following code, but for a valid set of credentials, it returned
error "User not known to the underlying authentication module". Any help
would be appreciated.

Thanks,
Siddharth.


struct pam_conv pam_conv = {login_conv, NULL};
int main ()
{
char* user_name = "siddharth";
char* pass_word = "siddharth123";

if ((pam_start("check_user", user_name, &pam_conv, &pamh))
                 != PAM_SUCCESS)
  return;

if (pam_set_item (pamh, PAM_USER, user_name) != PAM_SUCCESS)
    printf ("Cannot set Item\n");  // user name

if (pam_set_item (pamh, PAM_AUTHTOK, pass_word) != PAM_SUCCESS)
    printf ("Cannot set Item\n"); // password

int retcode = pam_authenticate(pamh, 0);
int failcount = 0;
while((failcount++ < 5) &&
    ((retcode == PAM_AUTH_ERR) ||
    (retcode == PAM_USER_UNKNOWN) ||
    (retcode == PAM_CRED_INSUFFICIENT) ||
    (retcode == PAM_AUTHINFO_UNAVAIL)))
{
    pam_get_item(pamh, PAM_USER, &(const void *)user_name);
    printf("Login incorrect\n\n");
    pam_set_item(pamh,PAM_USER,NULL);
    retcode = pam_authenticate(pamh, 0);
}
}

int
login_conv(int num_msg, struct pam_message **msg,
struct pam_response **response, void *appdata_ptr)
{
  return PAM_SUCCESS; // we donot perform any conversation
}
0
Reply siddharth_aggarwal (1) 6/24/2003 12:56:33 PM


0 Replies
194 Views

(page loaded in 0.031 seconds)

Similiar Articles:













7/23/2012 9:51:26 PM


Reply: