1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
Index: Linux-PAM/modules/pam_unix/support.c
===================================================================
--- Linux-PAM/modules/pam_unix/support.c (revision 305)
+++ Linux-PAM/modules/pam_unix/support.c (working copy)
@@ -38,24 +38,25 @@
void _log_err(int err, pam_handle_t *pamh, const char *format,...)
{
- char *service = NULL;
- char logname[256];
va_list args;
+ const char tag[] = "(pam_unix) ";
+ char *mod_format;
+ int free_mod_format = 1;
- pam_get_item(pamh, PAM_SERVICE, (const void **) &service);
- if (service) {
- strncpy(logname, service, sizeof(logname));
- logname[sizeof(logname) - 1 - strlen("(pam_unix)")] = '\0';
- strncat(logname, "(pam_unix)", strlen("(pam_unix)"));
+ mod_format = malloc( 1 + sizeof(tag) + strlen(format));
+ if(mod_format == NULL) {
+ free_mod_format = 0;
+ mod_format = (char *) format;
} else {
- strncpy(logname, "pam_unix", sizeof(logname) - 1);
+ strcpy(mod_format, tag);
+ strcat( mod_format, format);
}
va_start(args, format);
- openlog(logname, LOG_CONS | LOG_PID, LOG_AUTH);
- vsyslog(err, format, args);
+ vsyslog(err | LOG_AUTH, mod_format, args);
va_end(args);
- closelog();
+
+ if (free_mod_format) free(mod_format);
}
/* this is a front-end for module-application conversations */
|