1 #include <security/pam_appl.h>
2 #include <security/pam_misc.h>
5 const struct pam_conv conv
= {
10 int main(int argc
, char *argv
[]) {
11 pam_handle_t
* pamh
= NULL
;
13 const char* user
= "nobody";
16 printf("Usage: app [username]\n");
22 retval
= pam_start("check_user", user
, &conv
, &pamh
);
24 // Are the credentials correct?
25 if (retval
== PAM_SUCCESS
) {
26 printf("Credentials accepted.\n");
27 retval
= pam_authenticate(pamh
, 0);
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);
36 // Did everything work?
37 if (retval
== PAM_SUCCESS
) {
38 printf("Authenticated\n");
40 printf("Not Authenticated\n");
43 // close PAM (end session)
44 if (pam_end(pamh
, retval
) != PAM_SUCCESS
) {
46 printf("check_user: failed to release authenticator\n");
50 return retval
== PAM_SUCCESS
? 0 : 1;
This page took 0.302902 seconds and 4 git commands to generate.