git.fiddlerwoaroof.com
Browse code

adds setcred handler

Greg Wiley authored on 28/03/2017 22:43:28
Showing 2 changed files
... ...
@@ -11,3 +11,8 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, cons
11 11
     printf("Authentication\n");
12 12
     return PAM_SUCCESS;
13 13
 }
14
+
15
+PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv) {
16
+    printf("Set cred\n");
17
+    return PAM_SUCCESS;
18
+}
... ...
@@ -23,6 +23,14 @@ int pam_sm_authenticate_returns_success() {
23 23
     return result == PAM_SUCCESS;
24 24
 }
25 25
 
26
+int pam_sm_setcred_returns_success() {
27
+    //when
28
+    int result = pam_sm_setcred(NULL, 0, 0, NULL);
29
+
30
+    //then
31
+    return result == PAM_SUCCESS;
32
+}
33
+
26 34
 int main(int argc, char* argv[]) {
27 35
     int test1_result = pam_sm_acct_mgmt_returns_successs();
28 36
     if (!test1_result) {
... ...
@@ -34,7 +42,13 @@ int main(int argc, char* argv[]) {
34 42
         printf("acct auth failed\n");
35 43
     }
36 44
 
37
-    if (test1_result && test2_result) {
45
+    int test3_result = pam_sm_setcred_returns_success();
46
+    if (!test3_result) {
47
+        printf("set cred failed\n");
48
+    }
49
+
50
+
51
+    if (test1_result && test2_result && test3_result) {
38 52
         printf("success!\n");
39 53
     } else {
40 54
         printf("fail\n");