problem getting password in a pam module

Mohsen A. Momeni m.alimomeni at gmail.com
Tue Nov 21 10:49:19 UTC 2006


Hi,
I use the below code to get user and password from pam, but there is a
problem for password.
Password is (null) when I call "rc = pam_get_item (pamh, PAM_AUTHTOK, (const
void **) &p);"
what is the problem with the code?

Regards,


 53   D(("get user returned error: %s", pam_strerror(pamh,retval)));
 55   int rc;
 56   char *user=NULL;
 57   char *p=NULL;
 58   int use_first_pass = 0, try_first_pass = 0;
 59   int i;
 60
 61   for (i = 0; i < argc; i++)
 62   {
 63     if (!strcmp (argv[i], "use_first_pass"))
 64       use_first_pass = 1;
 65     else if (!strcmp (argv[i], "try_first_pass"))
 66       try_first_pass = 1;
 72   }
 73   rc = pam_get_user(pamh,(const char **) &user, NULL);
 74   if (rc != PAM_SUCCESS)
 75   {
 76     D(("get user returned error: %s", pam_strerror(pamh,rc)));
 78     return rc;
 79   }

 82   if (user == NULL || *user == '\0')
 83   {
 84     D(("username not known"));
 85     rc = pam_set_item(pamh, PAM_USER, (const char *) DEFAULT_USER);
 86     if (rc != PAM_SUCCESS)
 87       return PAM_USER_UNKNOWN;
 88   }
 89   //user = NULL;                                            /* clean up
*/
 90
 91   rc = pam_get_item (pamh, PAM_AUTHTOK, (const void **) &p);
 92   syslog (LOG_ERR, "pass: %s", p);
 93   syslog (LOG_ERR, "user: %s", user);
 94   return PAM_SUCCESS;
 95   if (rc == PAM_SUCCESS && (use_first_pass || try_first_pass))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pam-list/attachments/20061121/1902720c/attachment.htm>


More information about the Pam-list mailing list