authme-unix/src/pauthme.c
int
authme_request_password(pam_handle_t * pamh, const char * prompt,
                       const char **password)
{
    int err;
    struct pam_conv *pcnv;
    struct pam_message *pmsg;
    struct pam_response *prsp;


    authme_do_log(TRUE, LOG_DEBUG,
                 "(%s) Asking for password",
                 AUTHME_MODULE_NAME);
    return PAM_SUCCESS;

    /* Old stuff under here */

    if ((err = pam_get_item(pamh, 
                            PAM_CONV, 
                            (const void **) &pcnv)) != PAM_SUCCESS)
    {

        authme_do_log(FALSE, LOG_ERR,
                     "(%s) Error retrieving PAM_CONV - %s",
                     AUTHME_MODULE_NAME,
                     pam_strerror(pamh, err));
        return err;
    }

    if (pcnv == NULL)
    {
        authme_do_log(FALSE, LOG_ERR, "(%s) Error retrieving PAM_CONV",
                     AUTHME_MODULE_NAME);
        return PAM_CONV_ERR;
    }

    /* Have the conversation function! */
    pmsg = (struct pam_message *) calloc(1, sizeof(*pmsg));
    if (pmsg == NULL)
    {
        authme_do_log(FALSE, LOG_CRIT, "(%s) Unable to obtain memory",
                     AUTHME_MODULE_NAME);
        return PAM_SYSTEM_ERR;
    }

    pmsg->msg_style = PAM_PROMPT_ECHO_OFF;
    pmsg->msg = prompt;
    prsp = NULL;

    (pcnv->conv)(1, (const struct pam_message **) &pmsg, &prsp, 
                 pcnv->appdata_ptr);

    /* Retrieve the password ! */
    *password = strdup(prsp[0].resp);
                
    /* Clean up */
    free (prsp);
    free (pmsg);

    return PAM_SUCCESS;

}
/* Single function to ask for a password */
Single function to ask for a password
Single function to ask for a password
int
authme_request_password(pam_handle_t * pamh, const char * prompt,
                       const char **password)
{
    int err;
    struct pam_conv *pcnv;
    struct pam_message *pmsg;
    struct pam_response *prsp;
    authme_do_log(TRUE, LOG_DEBUG,
                 "(%s) Asking for password",
                 AUTHME_MODULE_NAME);
    return PAM_SUCCESS;
    if ((err = pam_get_item(pamh, 
                            PAM_CONV, 
                            (const void **) &pcnv)) != PAM_SUCCESS)
    {
        authme_do_log(FALSE, LOG_ERR,
                     "(%s) Error retrieving PAM_CONV - %s",
                     AUTHME_MODULE_NAME,
                     pam_strerror(pamh, err));
        return err;
    }
    if (pcnv == NULL)
    {
        authme_do_log(FALSE, LOG_ERR, "(%s) Error retrieving PAM_CONV",
                     AUTHME_MODULE_NAME);
        return PAM_CONV_ERR;
    }
    pmsg = (struct pam_message *) calloc(1, sizeof(*pmsg));
    if (pmsg == NULL)
    {
        authme_do_log(FALSE, LOG_CRIT, "(%s) Unable to obtain memory",
                     AUTHME_MODULE_NAME);
        return PAM_SYSTEM_ERR;
    }
    pmsg->msg_style = PAM_PROMPT_ECHO_OFF;
    pmsg->msg = prompt;
    prsp = NULL;
    (pcnv->conv)(1, (const struct pam_message **) &pmsg, &prsp, 
                 pcnv->appdata_ptr);
    *password = strdup(prsp[0].resp);
    free (prsp);
    free (pmsg);
    return PAM_SUCCESS;
}
int authme_request_password ( pam_handle_t * pamh , const char * prompt , const char * * password ) { int err ; struct pam_conv * pcnv ; struct pam_message * pmsg ; struct pam_response * prsp ; authme_do_log ( TRUE , LOG_DEBUG , " " , AUTHME_MODULE_NAME ) ; return PAM_SUCCESS ; if ( ( err = pam_get_item ( pamh , PAM_CONV , ( const void * * ) & pcnv ) ) != PAM_SUCCESS ) { authme_do_log ( FALSE , LOG_ERR , " " , AUTHME_MODULE_NAME , pam_strerror ( pamh , err ) ) ; return err ; } if ( pcnv == NULL ) { authme_do_log ( FALSE , LOG_ERR , " " , AUTHME_MODULE_NAME ) ; return PAM_CONV_ERR ; } pmsg = ( struct pam_message * ) calloc ( 1 , sizeof ( * pmsg ) ) ; if ( pmsg == NULL ) { authme_do_log ( FALSE , LOG_CRIT , " " , AUTHME_MODULE_NAME ) ; return PAM_SYSTEM_ERR ; } pmsg -> msg_style = PAM_PROMPT_ECHO_OFF ; pmsg -> msg = prompt ; prsp = NULL ; ( pcnv -> conv ) ( 1 , ( const struct pam_message * * ) & pmsg , & prsp , pcnv -> appdata_ptr ) ; * password = strdup ( prsp [ 0 ] . resp ) ; free ( prsp ) ; free ( pmsg ) ; return PAM_SUCCESS ; }
Single function to ask for a password
Single function to ask for a password
/* Old stuff under here */ /* Have the conversation function! */ /* Retrieve the password ! */ /* Clean up */