pam_get_item() question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am attempting to get the pw from a user through the pam_get_item() function call. here is my code, if someone could give me some information as to why it is causing the display manager to crash that would be great.

loading module from /etc/pam.d/xdm & gdm
auth   sufficient   pam_tester.so   try_first_pass

my code:
/* PAM includes */
#include <security/pam_modules.h>
#include <security/_pam_macros.h>
#include <security/pam_appl.h>

/* PAM definitions */
#define PAM_SM_ACCOUNT
#define PAM_SM_AUTH
#define PAM_SM_PASSWORD
#define PAM_SM_SESSION

/* Handle our authentication process */
PAM_EXTERN
int pam_sm_authenticate( pam_handle_t *pamh, int flags, int argc,
                        const char **argv )
{
   int retval;
   udataptr myUser = &localUser;
   myConfigPtr myConfig = &localConfig;
   char user[15];
   char *password;
   myUser->usrname=user;
   char error_msg[30];

if( ( retval = pam_get_user( pamh, &( myUser->usrname ), "PAM_test login:" ) != PAM_SUCCESS ) ) {
strcpy( error_msg, "Could not obtain user name: " );
strcat( error_msg, myUser->usrname );
_pam_log( LOG_ERR, error_msg, pam_strerror( pamh, retval ) );
}


if( ( retval = pam_get_user( pamh, &( myUser->usrname ), "PAM_test login:" ) == PAM_SUCCESS ) ) {
strcpy( error_msg, "Obtained username: " );
strcat( error_msg, myUser->usrname );
_pam_log( LOG_ERR, error_msg, pam_strerror( pamh, retval ) );
}


if( pam_get_item( pamh, PAM_AUTHTOK, ( const void ** ) &password ) != PAM_SUCCESS ) {
_pam_log( LOG_ERR, "Error retrieving password" );
return 1;
} else {
if( strlen( password ) != NULL ) {
strcpy( myUser->password, password );
} else {
_pam_log( LOG_ERR, "Unable to retrive password" );
return 1;
}


So far it successfully gathers our username but any call to the pam_get_item() completely crashes the display

--
Jason Gerfen
jason.gerfen@xxxxxxxxxxxx

"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
            ~The Red Green show

_______________________________________________

Pam-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/pam-list

[Index of Archives]     [Fedora Users]     [Kernel]     [Red Hat Install]     [Linux for the blind]     [Gimp]

  Powered by Linux