| 123456789101112131415161718192021222324252627282930313233343536 |
- /*
- * pamtest.c - minimal PAM client for testing pam_fp.so via the "fptest" service.
- * Build: gcc -O2 -Wall -o pamtest pamtest.c -lpam
- * Run: ./pamtest <username> (from a terminal; touch sensor or type password)
- */
- #include <security/pam_appl.h>
- #include <stdio.h>
- #include <stdlib.h>
- static int noop_conv(int n, const struct pam_message **m,
- struct pam_response **r, void *d)
- {
- (void)n;
- (void)m;
- (void)r;
- (void)d;
- return PAM_CONV_ERR;
- }
- int main(int argc, char **argv)
- {
- const char *user = argc > 1 ? argv[1] : getenv("USER");
- struct pam_conv conv = { noop_conv, NULL };
- pam_handle_t *pamh = NULL;
- int ret;
- ret = pam_start("fptest", user, &conv, &pamh);
- if (ret != PAM_SUCCESS) {
- printf("pam_start: %s\n", pam_strerror(pamh, ret));
- return 2;
- }
- ret = pam_authenticate(pamh, 0);
- printf("\npam_authenticate => %d (%s)\n", ret, pam_strerror(pamh, ret));
- pam_end(pamh, ret);
- return ret == PAM_SUCCESS ? 0 : 1;
- }
|