summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2013-03-06 21:42:40 +0000
committersthen <sthen@openbsd.org>2013-03-06 21:42:40 +0000
commit4a1d3eaab3099cdab0ba2f7230cb3a914c520749 (patch)
tree1d43116713d7524f8d13dcc4791edeb33d6717ff
parentsync yyerror() with version in bgpd so that it logs to syslog when daemonized. (diff)
downloadwireguard-openbsd-4a1d3eaab3099cdab0ba2f7230cb3a914c520749.tar.xz
wireguard-openbsd-4a1d3eaab3099cdab0ba2f7230cb3a914c520749.zip
as done in ospf{,6}d/relayd, sync yyerror in various other daemons with
that from bgpd, so that it logs to syslog when daemonized.
-rw-r--r--usr.sbin/dvmrpd/parse.y12
-rw-r--r--usr.sbin/ifstated/ifstated.h3
-rw-r--r--usr.sbin/ifstated/parse.y10
-rw-r--r--usr.sbin/ldpd/parse.y13
-rw-r--r--usr.sbin/ripd/parse.y13
-rw-r--r--usr.sbin/smtpd/parse.y11
-rw-r--r--usr.sbin/smtpd/smtpd.h6
-rw-r--r--usr.sbin/snmpd/parse.y11
-rw-r--r--usr.sbin/snmpd/snmpd.h3
-rw-r--r--usr.sbin/ypldap/parse.y11
-rw-r--r--usr.sbin/ypldap/ypldap.h3
11 files changed, 61 insertions, 35 deletions
diff --git a/usr.sbin/dvmrpd/parse.y b/usr.sbin/dvmrpd/parse.y
index 5832c8df696..3cd88e91752 100644
--- a/usr.sbin/dvmrpd/parse.y
+++ b/usr.sbin/dvmrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.22 2010/12/31 21:22:42 guenther Exp $ */
+/* $OpenBSD: parse.y,v 1.23 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -358,14 +358,16 @@ struct keywords {
int
yyerror(const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/ifstated/ifstated.h b/usr.sbin/ifstated/ifstated.h
index 15b2787d8c4..78f67c000c0 100644
--- a/usr.sbin/ifstated/ifstated.h
+++ b/usr.sbin/ifstated/ifstated.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifstated.h,v 1.6 2010/02/04 13:50:14 stevesk Exp $ */
+/* $OpenBSD: ifstated.h,v 1.7 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2004 Ryan McBride
@@ -142,5 +142,6 @@ void log_warn(const char *, ...);
void log_warnx(const char *, ...);
void log_info(const char *, ...);
void log_debug(const char *, ...);
+void vlog(int, const char *, va_list);
__dead void fatal(const char *);
__dead void fatalx(const char *);
diff --git a/usr.sbin/ifstated/parse.y b/usr.sbin/ifstated/parse.y
index 24875a72f51..b5cd6d64498 100644
--- a/usr.sbin/ifstated/parse.y
+++ b/usr.sbin/ifstated/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.30 2010/08/03 18:42:40 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.31 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
@@ -355,13 +355,15 @@ int
yyerror(const char *fmt, ...)
{
va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index ed4bc2a7558..5b86208ffad 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.7 2010/09/01 13:54:54 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.8 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
#include "ldp.h"
#include "ldpd.h"
@@ -323,14 +324,16 @@ struct keywords {
int
yyerror(const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/ripd/parse.y b/usr.sbin/ripd/parse.y
index 8cb73eec7dc..9334e8d6943 100644
--- a/usr.sbin/ripd/parse.y
+++ b/usr.sbin/ripd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.28 2010/08/03 18:42:41 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.29 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -37,6 +37,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
#include "ripd.h"
#include "rip.h"
@@ -378,14 +379,16 @@ struct keywords {
int
yyerror(const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 32c96b39543..b6d3e96f19e 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.115 2013/02/17 12:28:30 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.116 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -47,6 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include <unistd.h>
#include <util.h>
@@ -928,13 +929,15 @@ int
yyerror(const char *fmt, ...)
{
va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index b9d7f344dea..154ee42ee4d 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.407 2013/02/15 22:43:21 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.408 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1130,6 +1130,10 @@ void imsgproc_reset_callback(struct imsgproc *, void (*)(struct imsg *, void *),
pid_t lka(void);
+/* log.c */
+void vlog(int, const char *, va_list);
+
+
/* lka_session.c */
void lka_session(uint64_t, struct envelope *);
void lka_session_forward_reply(struct forward_req *, int);
diff --git a/usr.sbin/snmpd/parse.y b/usr.sbin/snmpd/parse.y
index 878a18eff01..5f9c0ecfdb9 100644
--- a/usr.sbin/snmpd/parse.y
+++ b/usr.sbin/snmpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.23 2012/09/17 19:00:06 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.24 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -46,6 +46,7 @@
#include <stdio.h>
#include <netdb.h>
#include <string.h>
+#include <syslog.h>
#include "snmpd.h"
#include "mib.h"
@@ -458,13 +459,15 @@ int
yyerror(const char *fmt, ...)
{
va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h
index d144b7cc2a7..c425e9b6af6 100644
--- a/usr.sbin/snmpd/snmpd.h
+++ b/usr.sbin/snmpd/snmpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpd.h,v 1.41 2013/03/04 14:00:31 bluhm Exp $ */
+/* $OpenBSD: snmpd.h,v 1.42 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -445,6 +445,7 @@ void log_info(const char *, ...);
void log_debug(const char *, ...);
__dead void fatal(const char *);
__dead void fatalx(const char *);
+void vlog(int, const char *, va_list);
const char *log_in6addr(const struct in6_addr *);
const char *print_host(struct sockaddr_storage *, char *, size_t);
diff --git a/usr.sbin/ypldap/parse.y b/usr.sbin/ypldap/parse.y
index 24091d7e234..67c50c08cfe 100644
--- a/usr.sbin/ypldap/parse.y
+++ b/usr.sbin/ypldap/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.11 2012/04/30 11:28:25 jmatthew Exp $ */
+/* $OpenBSD: parse.y,v 1.12 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -47,6 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include <unistd.h>
#include "ypldap.h"
@@ -331,13 +332,15 @@ int
yyerror(const char *fmt, ...)
{
va_list ap;
+ char *nfmt;
file->errors++;
va_start(ap, fmt);
- fprintf(stderr, "%s:%d: ", file->name, yylval.lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
+ fatalx("yyerror asprintf");
+ vlog(LOG_CRIT, nfmt, ap);
va_end(ap);
+ free(nfmt);
return (0);
}
diff --git a/usr.sbin/ypldap/ypldap.h b/usr.sbin/ypldap/ypldap.h
index e7933e75cd7..b8f65ac7bfd 100644
--- a/usr.sbin/ypldap/ypldap.h
+++ b/usr.sbin/ypldap/ypldap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypldap.h,v 1.13 2012/04/30 11:28:25 jmatthew Exp $ */
+/* $OpenBSD: ypldap.h,v 1.14 2013/03/06 21:42:40 sthen Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -184,6 +184,7 @@ void log_warn(const char *, ...);
void log_warnx(const char *, ...);
void log_info(const char *, ...);
void log_debug(const char *, ...);
+void vlog(int, const char *, va_list);
__dead void fatal(const char *);
__dead void fatalx(const char *);