git.fiddlerwoaroof.com
Browse code

logger logs requester

Greg Wiley authored on 03/05/2017 00:39:00
Showing 2 changed files
... ...
@@ -40,13 +40,13 @@ public:
40 40
         case PAM_AUTH_ERR:
41 41
             facility = LOG_AUTHPRIV;
42 42
             priority = LOG_NOTICE;
43
-            message = authorizer_user_name + " " + token + " " + "fail";
43
+            message = requester_user_name + " " + authorizer_user_name + " " + token + " " + "fail";
44 44
             break;
45 45
 
46 46
         default:
47 47
             facility = LOG_AUTH;
48 48
             priority = LOG_ERR;
49
-            message = authorizer_user_name + " pam returned error";
49
+            message = requester_user_name + " " + authorizer_user_name + " pam returned error";
50 50
             break;
51 51
         }
52 52
 
... ...
@@ -84,7 +84,7 @@ int logs_failure()
84 84
 
85 85
     //then
86 86
     check (capture->facility == LOG_AUTHPRIV, "facility does not match");
87
-    check (capture->message == authorizer + " " + token + " " + "fail",
87
+    check (capture->message == requester + " " + authorizer + " " + token + " " + "fail",
88 88
            "message does not match");
89 89
     check (capture->priority == LOG_NOTICE, "priority does not match");
90 90
     check (capture->closed, "syslog not closed");
... ...
@@ -108,7 +108,7 @@ int logs_pam_service_error()
108 108
 
109 109
     //then
110 110
     check (capture->facility == LOG_AUTH, "facility does not match");
111
-    check (capture->message == authorizer + " pam returned error",
111
+    check (capture->message == requester + " " + authorizer + " pam returned error",
112 112
            "message does not match");
113 113
     check (capture->priority == LOG_ERR, "priority does not match");
114 114
     check (capture->closed, "syslog not closed");
... ...
@@ -132,83 +132,3 @@ int main (int numargs, char **args)
132 132
     return !run_tests();
133 133
 }
134 134
 
135
-/*
136
-int logged_priority = -1000;
137
-const char *logged_message = "";
138
-void fake_syslog (int priority, const char *message, ...)
139
-{
140
-    logged_priority = priority;
141
-    logged_message = message;
142
-}
143
-
144
-int close_log_invoked = 0;
145
-void fake_closelog (void)
146
-{
147
-    close_log_invoked = 1;
148
-}
149
-
150
-int opened_facility = -1000;
151
-const char *opened_program_name = "";
152
-int opened_logopt = -1000;
153
-void fake_openlog (const char *ident, int logopt, int facility)
154
-{
155
-    opened_facility = facility;
156
-    opened_program_name = ident;
157
-    opened_logopt = logopt;
158
-}
159
-
160
-RESET_VARS_START
161
-logged_priority = -1000;
162
-close_log_invoked = 0;
163
-opened_facility = -1000;
164
-const char *opened_program_name = "";
165
-int opened_logopt = -1000;
166
-RESET_VARS_END
167
-
168
-int test_log_success()
169
-{
170
-    // given
171
-
172
-    // when
173
-    log_success();
174
-
175
-    // then
176
-    checkint (LOG_AUTHPRIV, opened_facility, "facility");
177
-    checkint (LOG_NOTICE, logged_priority, "priority");
178
-    checkint (0, opened_logopt, "logopt");
179
-    check (close_log_invoked, "log closed");
180
-    checkstr ("pam_dual_control", opened_program_name, "program name");
181
-    checkstr ("dual control succeeded", logged_message, "logged message");
182
-    succeed();
183
-}
184
-
185
-int test_log_failure()
186
-{
187
-    //given
188
-
189
-    //when
190
-    log_failure();
191
-
192
-    //then
193
-    checkint (LOG_AUTHPRIV, opened_facility, "facility");
194
-    checkint (LOG_NOTICE, logged_priority, "priority");
195
-    checkint (0, opened_logopt, "logopt");
196
-    check (close_log_invoked, "log closed");
197
-    checkstr ("pam_dual_control", opened_program_name, "program name");
198
-    checkstr ("dual control failed", logged_message, "logged message");
199
-    succeed();
200
-}
201
-
202
-int test_runner()
203
-{
204
-    test (test_log_success);
205
-    test (test_log_failure);
206
-    succeed();
207
-}
208
-
209
-int main (int numargs, char **args)
210
-{
211
-    return !test_runner();
212
-}
213
-*/
214
-