Browse code
adds auth handler
Greg Wiley authored on 28/03/2017 22:34:07
Showing 4 changed files
Showing 4 changed files
... | ... |
@@ -7,3 +7,7 @@ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const c |
7 | 7 |
return PAM_SUCCESS; |
8 | 8 |
} |
9 | 9 |
|
10 |
+PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { |
|
11 |
+ printf("Authentication\n"); |
|
12 |
+ return PAM_SUCCESS; |
|
13 |
+} |
... | ... |
@@ -13,12 +13,33 @@ int pam_sm_acct_mgmt_returns_successs() { |
13 | 13 |
return result == PAM_SUCCESS; |
14 | 14 |
} |
15 | 15 |
|
16 |
+int pam_sm_authenticate_returns_success() { |
|
17 |
+ //given |
|
18 |
+ |
|
19 |
+ //when |
|
20 |
+ int result = pam_sm_authenticate(NULL, 0, 0, NULL); |
|
21 |
+ |
|
22 |
+ //then |
|
23 |
+ return result == PAM_SUCCESS; |
|
24 |
+} |
|
25 |
+ |
|
16 | 26 |
int main(int argc, char* argv[]) { |
17 |
- if (pam_sm_acct_mgmt_returns_successs()) { |
|
18 |
- printf("success!"); |
|
27 |
+ int test1_result = pam_sm_acct_mgmt_returns_successs(); |
|
28 |
+ if (!test1_result) { |
|
29 |
+ printf("acct management failed\n"); |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ int test2_result = pam_sm_authenticate_returns_success(); |
|
33 |
+ if (!test2_result) { |
|
34 |
+ printf("acct auth failed\n"); |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ if (test1_result && test2_result) { |
|
38 |
+ printf("success!\n"); |
|
19 | 39 |
} else { |
20 |
- printf("fail"); |
|
40 |
+ printf("fail\n"); |
|
21 | 41 |
} |
22 | 42 |
return 0; |
23 | 43 |
} |
24 | 44 |
|
45 |
+ |