Module Name: src
Committed By: abs
Date: Sat Jul 14 20:32:39 UTC 2012
Modified Files:
src/distrib/utils/libhack: syslog.c
Log Message:
Add a check hack to ensure %m causes error message string to be shown
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/distrib/utils/libhack/syslog.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/utils/libhack/syslog.c
diff -u src/distrib/utils/libhack/syslog.c:1.6 src/distrib/utils/libhack/syslog.c:1.7
--- src/distrib/utils/libhack/syslog.c:1.6 Sat Feb 3 19:49:21 2007
+++ src/distrib/utils/libhack/syslog.c Sat Jul 14 20:32:39 2012
@@ -1,6 +1,8 @@
#include <sys/types.h>
#include <sys/syslog.h>
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include <stdarg.h>
void
@@ -25,10 +27,8 @@ syslog(int fac, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
+ vsyslog(fac, fmt, ap);
va_end(ap);
- (void)fprintf(stderr, "\n");
- fflush(stderr);
}
__strong_alias(_vsyslog, vsyslog)
@@ -36,6 +36,9 @@ void
vsyslog(int fac, const char *fmt, va_list ap)
{
(void)vfprintf(stderr, fmt, ap);
+ /* Cheap hack to ensure %m causes error message string to be shown */
+ if (strstr(fmt, "%m"))
+ (void)fprintf(stderr, " (%s)", strerror(errno));
(void)fprintf(stderr, "\n");
fflush(stderr);
}