Re: Simple PAM authentication code?

From: Rob Pitt (rob_at_motionpath.com)
Date: 09/30/05

  • Next message: Efren Bravo: "pppd server help"
    Date: Fri, 30 Sep 2005 19:30:27 +0100
    To: freebsd-questions@freebsd.org
    
    

    This is mostly taken from Linux Standards Base. Compile with -lpam -
    lpam_misc.

    HTH

    - RP

    #include <security/pam_appl.h>
    #include <security/pam_misc.h>
    #include <stdio.h>

    int main(int argc, char *argv[])
    {
             static struct pam_conv conv;
             conv.conv = misc_conv;
             conv.appdata_ptr = NULL;

             pam_handle_t *pamh;
             int pam_status;
             char *user;

             pam_status = pam_start("testing", NULL, &conv, &pamh);

             if (pam_status == PAM_SUCCESS)
                     pam_status = pam_authenticate(pamh, 0);

             if (pam_status == PAM_SUCCESS) {
                     pam_get_item(pamh, PAM_USER, (const void **)&user);
                     fprintf(stdout, "Greetings %s\n", user);
             } else {
                     printf("%s\n", pam_strerror(pamh, pam_status));
             }

             pam_end(pamh, pam_status);
    }

    On 30 Sep 2005, at 18:46, Brian J. McGovern wrote:

    > Could someone point me at a short, straight forward bit of code that
    > validates a given username and password via PAM? I've tried writing
    > a short
    > app to make sure PAM is working the way I want to locally, but no
    > matter how
    > good the info, I'm getting an authentication denied, so I know I'm
    > missing something.
    >
    > The openpam site didn't seem to helpful documentation wise, and my
    > connection to
    > download the source seems to be timing out at the moment...
    >
    > -B
    > _______________________________________________
    > freebsd-questions@freebsd.org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > To unsubscribe, send any mail to "freebsd-questions-
    > unsubscribe@freebsd.org"
    >

    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"


  • Next message: Efren Bravo: "pppd server help"