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
42
43
44
45
46
47
|
diff -Nru mgetty-1.1.33.orig/logfile.c mgetty-1.1.33/logfile.c
--- mgetty-1.1.33.orig/logfile.c 2004-11-08 22:07:29.000000000 +0200
+++ mgetty-1.1.33/logfile.c 2005-04-19 22:44:43.362511504 +0300
@@ -58,10 +58,10 @@
/* Most systems have these variables but do not declare them. On many
of those systems that _do_ declare them, it won't hurt */
-#if !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined(__OpenBSD__) && !defined(__GLIBC__) && !defined(__MACH__)
+/*#if !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined(__OpenBSD__) && !defined(__GLIBC__) && !defined(__MACH__)
extern int sys_nerr;
extern char *sys_errlist[];
-#endif
+#endif*/
/* Interactive Unix is a little bit braindead - does not have atexit(),
*/
@@ -211,6 +211,7 @@
va_list pvar;
int errnr;
char * p;
+char *error_string;
static int first_open = TRUE;
if ( level > log_level ) /* log level high enough? */
@@ -327,12 +328,20 @@
}
else /* ERROR or FATAL */
{
+ error_string = strerror (errnr);
+ if ( error_string == NULL )
+ {
+ if ( errno == EINVAL )
+ error_string = "<error not in list>";
+ else
+ error_string = "<error calling strerror()>";
+ }
+
fprintf(log_fp, "\n%02d/%02d %02d:%02d:%02d %s %s: %s",
tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
log_infix, ws,
- ( errnr <= sys_nerr ) ? sys_errlist[errnr]:
- "<error not in list>" );
+ strerror (errnr));
#ifdef SYSLOG
syslog( level == L_FATAL? LOG_ALERT: LOG_ERR, "%s: %m", ws );
#endif
|