summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/parse.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2017-02-15 20:00:16 +0000
committerkrw <krw@openbsd.org>2017-02-15 20:00:16 +0000
commitae9c7f69f4d3f7fcc7afacc2353ea0e4ab3f532b (patch)
treed360292894e9519f0404efb64b1517e69e3b6868 /sbin/dhclient/parse.c
parentAdopt the common verbiage other log.[ch] daemons use to describe '-d'. (diff)
downloadwireguard-openbsd-ae9c7f69f4d3f7fcc7afacc2353ea0e4ab3f532b.tar.xz
wireguard-openbsd-ae9c7f69f4d3f7fcc7afacc2353ea0e4ab3f532b.zip
Use new log.[ch] functions in parse_warn().
Simplify the "^" placing logic and make it apply to log entries as well as terminal output. Since dhclient(8) can be re-exec'd for various reasons after going daemon, make sure we don't try to log to stderr if it isn't a TTY.
Diffstat (limited to 'sbin/dhclient/parse.c')
-rw-r--r--sbin/dhclient/parse.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c
index 8de21943414..57bb6e7e30e 100644
--- a/sbin/dhclient/parse.c
+++ b/sbin/dhclient/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.42 2017/02/12 13:15:50 krw Exp $ */
+/* $OpenBSD: parse.c,v 1.43 2017/02/15 20:00:16 krw Exp $ */
/* Common parser code for dhcpd and dhclient. */
@@ -420,44 +420,20 @@ void
parse_warn(char *msg)
{
static char spaces[81];
- static char mbuf[1024];
- struct iovec iov[6];
- size_t iovcnt;
int i;
- snprintf(mbuf, sizeof(mbuf), "%s line %d: %s", tlname, lexline, msg);
-
-#ifndef DEBUG
- syslog(LOG_ERR, "%s", mbuf);
- syslog(LOG_ERR, "%s", token_line);
- if (lexchar < 81)
- syslog(LOG_ERR, "%*c", lexchar, '^');
-#endif
-
- if (log_perror) {
- iov[0].iov_base = mbuf;
- iov[0].iov_len = strlen(mbuf);
- iov[1].iov_base = "\n";
- iov[1].iov_len = 1;
- iov[2].iov_base = token_line;
- iov[2].iov_len = strlen(token_line);
- iov[3].iov_base = "\n";
- iov[3].iov_len = 1;
- iovcnt = 4;
- if (lexchar < 81) {
- for (i = 0; i < lexchar; i++) {
- if (token_line[i] == '\t')
- spaces[i] = '\t';
- else
- spaces[i] = ' ';
- }
- iov[4].iov_base = spaces;
- iov[4].iov_len = lexchar - 1;
- iov[5].iov_base = "^\n";
- iov[5].iov_len = 2;
- iovcnt += 2;
+ log_warnx("%s line %d: %s", tlname, lexline, msg);
+ log_warnx("%s", token_line);
+ if (lexchar < sizeof(spaces)) {
+ memset(spaces, 0, sizeof(spaces));
+ for (i = 0; i < lexchar - 1; i++) {
+ if (token_line[i] == '\t')
+ spaces[i] = '\t';
+ else
+ spaces[i] = ' ';
}
- writev(STDERR_FILENO, iov, iovcnt);
}
+ log_warnx("%s^", spaces);
+
warnings_occurred = 1;
}