Date: Fri, 30 Sep 2005 19:30:27 +0100 From: Rob Pitt <rob@motionpath.com> To: freebsd-questions@freebsd.org Subject: Re: Simple PAM authentication code? Message-ID: <6E00FF16-452F-4710-A9B7-C5BC3DFA476D@motionpath.com> In-Reply-To: <200509301746.j8UHkh6x038676@spoon.beta.com> References: <200509301746.j8UHkh6x038676@spoon.beta.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6E00FF16-452F-4710-A9B7-C5BC3DFA476D>