Home detection fix
[mirrors/pam-ftpfuck.git] / src / test.c
CommitLineData
4e98ead2
JL
1#include <security/pam_appl.h>
2#include <security/pam_misc.h>
3#include <stdio.h>
4
5const struct pam_conv conv = {
6 misc_conv,
7 NULL
8};
9
10int main(int argc, char *argv[]) {
11 pam_handle_t* pamh = NULL;
12 int retval;
13 const char* user = "nobody";
14
15 if(argc != 2) {
16 printf("Usage: app [username]\n");
17 exit(1);
18 }
19
20 user = argv[1];
21
22 retval = pam_start("check_user", user, &conv, &pamh);
23
24 // Are the credentials correct?
25 if (retval == PAM_SUCCESS) {
26 printf("Credentials accepted.\n");
27 retval = pam_authenticate(pamh, 0);
28 }
29
30 // Can the accound be used at this time?
31 if (retval == PAM_SUCCESS) {
32 printf("Account is valid.\n");
33 retval = pam_acct_mgmt(pamh, 0);
34 }
35
36 // Did everything work?
37 if (retval == PAM_SUCCESS) {
38 printf("Authenticated\n");
39 } else {
40 printf("Not Authenticated\n");
41 }
42
43 // close PAM (end session)
44 if (pam_end(pamh, retval) != PAM_SUCCESS) {
45 pamh = NULL;
46 printf("check_user: failed to release authenticator\n");
47 exit(1);
48 }
49
50 return retval == PAM_SUCCESS ? 0 : 1;
51}
This page took 0.154055 seconds and 4 git commands to generate.