Browse code
adds system logging
Greg Wiley authored on 03/04/2017 21:55:26
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
#include <security/pam_appl.h> |
2 | 2 |
#include <security/pam_modules.h> |
3 | 3 |
#include <stdio.h> |
4 |
+#include "logging.h" |
|
4 | 5 |
|
5 | 6 |
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) { |
6 | 7 |
printf("Acct mgmt\n"); |
... | ... |
@@ -9,6 +10,8 @@ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const c |
9 | 10 |
|
10 | 11 |
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { |
11 | 12 |
printf("Authentication\n"); |
13 |
+ log_dual_control(); |
|
14 |
+ |
|
12 | 15 |
return PAM_SUCCESS; |
13 | 16 |
} |
14 | 17 |
|
... | ... |
@@ -3,6 +3,11 @@ |
3 | 3 |
#include <security/pam_modules.h> |
4 | 4 |
#include <stdio.h> |
5 | 5 |
|
6 |
+int log_dual_control_invoked = 0; |
|
7 |
+void log_dual_control() { |
|
8 |
+ log_dual_control_invoked = 1; |
|
9 |
+} |
|
10 |
+ |
|
6 | 11 |
int pam_sm_acct_mgmt_returns_successs() { |
7 | 12 |
// given |
8 | 13 |
|
... | ... |
@@ -31,6 +36,16 @@ int pam_sm_setcred_returns_success() { |
31 | 36 |
return result == PAM_SUCCESS; |
32 | 37 |
} |
33 | 38 |
|
39 |
+int pam_sm_authenticate_invokes_log() { |
|
40 |
+ // given |
|
41 |
+ log_dual_control_invoked = 0; |
|
42 |
+ |
|
43 |
+ //when |
|
44 |
+ pam_sm_authenticate(NULL, 0, 0, NULL); |
|
45 |
+ return log_dual_control_invoked; |
|
46 |
+} |
|
47 |
+ |
|
48 |
+ |
|
34 | 49 |
int main(int argc, char* argv[]) { |
35 | 50 |
int test1_result = pam_sm_acct_mgmt_returns_successs(); |
36 | 51 |
if (!test1_result) { |
... | ... |
@@ -47,11 +62,19 @@ int main(int argc, char* argv[]) { |
47 | 62 |
fprintf(stderr, "set cred failed\n"); |
48 | 63 |
} |
49 | 64 |
|
65 |
+ int test4_result = pam_sm_authenticate_invokes_log(); |
|
66 |
+ if (!test4_result) { |
|
67 |
+ fprintf(stderr, "authenticate invokes log failed\n"); |
|
68 |
+ } |
|
50 | 69 |
|
51 |
- if (test1_result && test2_result && test3_result) { |
|
70 |
+ if (test1_result && test2_result && test3_result && test4_result) { |
|
71 |
+ fprintf(stderr, "success\n"); |
|
52 | 72 |
return 0; |
53 | 73 |
} else { |
54 | 74 |
return 1; |
55 | 75 |
} |
56 | 76 |
} |
57 | 77 |
|
78 |
+ |
|
79 |
+ |
|
80 |
+ |