summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-10-31 02:57:16 +0000
committerderaadt <deraadt@openbsd.org>2015-10-31 02:57:16 +0000
commit1778bf5bfab38adeb6a507dfbd135daf8f1fbf3e (patch)
tree0f69490663276b5fdaf25fd5acfeccd6a1b7c1ba /lib/libc
parentexpose the sysctl backing getloadavg(3) all the time, now that more (diff)
downloadwireguard-openbsd-1778bf5bfab38adeb6a507dfbd135daf8f1fbf3e.tar.xz
wireguard-openbsd-1778bf5bfab38adeb6a507dfbd135daf8f1fbf3e.zip
Do not include a timestamp in the syslog message. There is no need --
syslogd will fill it in immediately upon reception on the other side of sendsyslog(2). Our libc only talks to our syslogd, which will fix the timestamp before forwarding. syslog_r has done this for a long time already. ok tedu bluhm
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/syslog.c14
-rw-r--r--lib/libc/gen/syslog_r.c30
-rw-r--r--lib/libc/hidden/syslog.h4
3 files changed, 13 insertions, 35 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index ccbf5c03151..501535fb9d3 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslog.c,v 1.32 2015/09/12 14:30:31 guenther Exp $ */
+/* $OpenBSD: syslog.c,v 1.33 2015/10/31 02:57:16 deraadt Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -35,16 +35,6 @@
static struct syslog_data sdata = SYSLOG_DATA_INIT;
-static size_t
-gettime(char *buf, size_t maxsize)
-{
- time_t now;
-
- (void)time(&now);
- return (strftime(buf, maxsize, "%h %e %T ", localtime(&now)));
-}
-
-
/*
* syslog, vsyslog --
* print message on log file; output is intended for syslogd(8).
@@ -63,7 +53,7 @@ DEF_WEAK(syslog);
void
vsyslog(int pri, const char *fmt, va_list ap)
{
- __vsyslog_r(pri, &sdata, &gettime, fmt, ap);
+ __vsyslog_r(pri, &sdata, 0, fmt, ap);
}
DEF_WEAK(vsyslog);
diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c
index 8da599aef64..d5ae4aa88c1 100644
--- a/lib/libc/gen/syslog_r.c
+++ b/lib/libc/gen/syslog_r.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslog_r.c,v 1.9 2015/09/12 14:30:31 guenther Exp $ */
+/* $OpenBSD: syslog_r.c,v 1.10 2015/10/31 02:57:16 deraadt Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -61,19 +61,16 @@ DEF_WEAK(syslog_r);
void
vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
{
- __vsyslog_r(pri, data, NULL, fmt, ap);
+ __vsyslog_r(pri, data, 1, fmt, ap);
}
DEF_WEAK(vsyslog_r);
/*
- * This is used by both syslog_r and syslog. The latter supplies
- * a non-NULL gettime callback for filling in the date, but we also
- * use the presence of that callback to decide whether it's safe
- * to call strerror and what the name of the caller is
+ * This is used by both syslog_r and syslog.
*/
void
__vsyslog_r(int pri, struct syslog_data *data,
- size_t (*gettime)(char *, size_t), const char *fmt, va_list ap)
+ int reentrant, const char *fmt, va_list ap)
{
int cnt;
char ch, *p, *t;
@@ -88,7 +85,7 @@ __vsyslog_r(int pri, struct syslog_data *data,
if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
syslog_r(INTERNALLOG, data,
"syslog%s: unknown facility/priority: %x",
- gettime != NULL ? "" : "_r", pri);
+ reentrant ? "_r" : "", pri);
pri &= LOG_PRIMASK|LOG_FACMASK;
}
@@ -120,15 +117,6 @@ __vsyslog_r(int pri, struct syslog_data *data,
if (data->log_stat & LOG_CONS)
conp = p;
- /*
- * syslogd will expand time automagically for reentrant case, and
- * for normal case, invoke the callback to do it just do like before
- */
- if (gettime != NULL) {
- prlen = gettime(p, tbuf_left);
- DEC();
- }
-
if (data->log_stat & LOG_PERROR)
stdp = p;
if (data->log_tag == NULL)
@@ -157,12 +145,12 @@ __vsyslog_r(int pri, struct syslog_data *data,
for (t = fmt_cpy, fmt_left = FMT_LEN; (ch = *fmt); ++fmt) {
if (ch == '%' && fmt[1] == 'm') {
++fmt;
- if (gettime != NULL) {
- prlen = snprintf(t, fmt_left, "%s",
- strerror(saved_errno));
- } else {
+ if (reentrant) {
prlen = snprintf(t, fmt_left, "Error %d",
saved_errno);
+ } else {
+ prlen = snprintf(t, fmt_left, "%s",
+ strerror(saved_errno));
}
if (prlen < 0)
prlen = 0;
diff --git a/lib/libc/hidden/syslog.h b/lib/libc/hidden/syslog.h
index 867a05ca7ea..1773baaef26 100644
--- a/lib/libc/hidden/syslog.h
+++ b/lib/libc/hidden/syslog.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslog.h,v 1.1 2015/09/12 14:30:31 guenther Exp $ */
+/* $OpenBSD: syslog.h,v 1.2 2015/10/31 02:57:16 deraadt Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
@@ -24,7 +24,7 @@ int sendsyslog(const char *, __size_t);
PROTO_NORMAL(sendsyslog);
__BEGIN_HIDDEN_DECLS
-void __vsyslog_r(int, struct syslog_data *, __size_t (*)(char *, __size_t),
+void __vsyslog_r(int, struct syslog_data *, int,
const char *, __va_list);
__END_HIDDEN_DECLS