* auth/radius.c (mu_grad_logger): New function.
(mu_radius_module_init): Install a custom logger function.
Showing
2 changed files
with
54 additions
and
0 deletions
1 | 2008-06-03 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | * auth/radius.c (mu_grad_logger): New function. | ||
4 | (mu_radius_module_init): Install a custom logger function. | ||
5 | |||
1 | 2008-05-31 Sergey Poznyakoff <gray@gnu.org.ua> | 6 | 2008-05-31 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 7 | ||
3 | * libproto/include/amd.h (struct _amd_message.has_new_msg): New | 8 | * libproto/include/amd.h (struct _amd_message.has_new_msg): New | ... | ... |
... | @@ -30,6 +30,7 @@ | ... | @@ -30,6 +30,7 @@ |
30 | #ifdef HAVE_STRINGS_H | 30 | #ifdef HAVE_STRINGS_H |
31 | # include <strings.h> | 31 | # include <strings.h> |
32 | #endif | 32 | #endif |
33 | #include <inttostr.h> | ||
33 | 34 | ||
34 | #include <mailutils/list.h> | 35 | #include <mailutils/list.h> |
35 | #include <mailutils/iterator.h> | 36 | #include <mailutils/iterator.h> |
... | @@ -161,6 +162,53 @@ parse_pairlist (grad_avp_t **plist, char *input) | ... | @@ -161,6 +162,53 @@ parse_pairlist (grad_avp_t **plist, char *input) |
161 | ((cfg) && \ | 162 | ((cfg) && \ |
162 | ((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request)) | 163 | ((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request)) |
163 | 164 | ||
165 | static void | ||
166 | mu_grad_logger(int level, | ||
167 | const grad_request_t *req, | ||
168 | const grad_locus_t *loc, | ||
169 | const char *func_name, int en, | ||
170 | const char *fmt, va_list ap) | ||
171 | { | ||
172 | static int mlevel[] = { | ||
173 | MU_DIAG_EMERG, | ||
174 | MU_DIAG_ALERT, | ||
175 | MU_DIAG_CRIT, | ||
176 | MU_DIAG_ERROR, | ||
177 | MU_DIAG_WARNING, | ||
178 | MU_DIAG_NOTICE, | ||
179 | MU_DIAG_INFO, | ||
180 | MU_DIAG_DEBUG | ||
181 | }; | ||
182 | |||
183 | char *pfx = NULL; | ||
184 | if (loc) | ||
185 | { | ||
186 | char buf[INT_STRLEN_BOUND(uintmax_t)]; | ||
187 | char *p = umaxtostr (loc->line, buf); | ||
188 | size_t size = strlen (loc->file) + 1 + strlen (p) + 2 + strlen (fmt) + 1; | ||
189 | if (func_name) | ||
190 | size += strlen (func_name) + 1; | ||
191 | pfx = malloc (size); | ||
192 | if (pfx) | ||
193 | { | ||
194 | strcpy (pfx, loc->file); | ||
195 | strcat (pfx, ":"); | ||
196 | strcat (pfx, p); | ||
197 | strcat (pfx, ":"); | ||
198 | if (func_name) | ||
199 | { | ||
200 | strcat (pfx, func_name); | ||
201 | strcat (pfx, ":"); | ||
202 | } | ||
203 | strcat (pfx, " "); | ||
204 | strcat (pfx, fmt); | ||
205 | } | ||
206 | } | ||
207 | mu_diag_voutput (mlevel[level & L_PRIMASK], pfx ? pfx : fmt, ap); | ||
208 | if (pfx) | ||
209 | free(pfx); | ||
210 | } | ||
211 | |||
164 | int | 212 | int |
165 | mu_radius_module_init (void *data) | 213 | mu_radius_module_init (void *data) |
166 | { | 214 | { |
... | @@ -169,6 +217,7 @@ mu_radius_module_init (void *data) | ... | @@ -169,6 +217,7 @@ mu_radius_module_init (void *data) |
169 | if (!NEED_RADIUS_P (cfg)) | 217 | if (!NEED_RADIUS_P (cfg)) |
170 | return 0; | 218 | return 0; |
171 | 219 | ||
220 | grad_set_logger (mu_grad_logger); | ||
172 | grad_config_dir = grad_estrdup (cfg->config_dir); | 221 | grad_config_dir = grad_estrdup (cfg->config_dir); |
173 | 222 | ||
174 | grad_path_init (); | 223 | grad_path_init (); | ... | ... |
-
Please register or sign in to post a comment