syslogd: Fix RFC3164 formatting, no space after <PRI> field
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
7343c55f6e
commit
bd5903509d
@ -1533,7 +1533,7 @@ void fprintlog_write(struct filed *f, struct iovec *iov, int iovcnt, int flags)
|
|||||||
if (f->f_type == F_FILE)
|
if (f->f_type == F_FILE)
|
||||||
logrotate(f);
|
logrotate(f);
|
||||||
|
|
||||||
if (writev(f->f_file, &iov[2], iovcnt - 2) < 0) {
|
if (writev(f->f_file, &iov[1], iovcnt - 1) < 0) {
|
||||||
int e = errno;
|
int e = errno;
|
||||||
|
|
||||||
/* If a named pipe is full, just ignore it for now */
|
/* If a named pipe is full, just ignore it for now */
|
||||||
@ -1580,7 +1580,7 @@ void fprintlog_write(struct filed *f, struct iovec *iov, int iovcnt, int flags)
|
|||||||
f->f_time = now;
|
f->f_time = now;
|
||||||
logit("\n");
|
logit("\n");
|
||||||
pushiov(iov, iovcnt, "\r\n");
|
pushiov(iov, iovcnt, "\r\n");
|
||||||
wallmsg(f, &iov[2], iovcnt - 2);
|
wallmsg(f, &iov[1], iovcnt - 1);
|
||||||
break;
|
break;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
|
|
||||||
@ -1598,9 +1598,9 @@ static int fmt3164(struct buf_msg *buffer, char *fmt, struct iovec *iov, size_t
|
|||||||
|
|
||||||
fmtlogit(buffer);
|
fmtlogit(buffer);
|
||||||
|
|
||||||
|
/* Notice difference to RFC5424, in RFC3164 there is *no* space! */
|
||||||
snprintf(buffer->pribuf, sizeof(buffer->pribuf), "<%d>", buffer->pri);
|
snprintf(buffer->pribuf, sizeof(buffer->pribuf), "<%d>", buffer->pri);
|
||||||
pushiov(iov, i, buffer->pribuf);
|
pushiov(iov, i, buffer->pribuf);
|
||||||
pushsp(iov, i);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sysklogd < 2.0 had the traditional BSD format for remote syslog
|
* sysklogd < 2.0 had the traditional BSD format for remote syslog
|
||||||
@ -1653,10 +1653,9 @@ static int fmt5424(struct buf_msg *buffer, char *fmt, struct iovec *iov, size_t
|
|||||||
usec /= 10;
|
usec /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RFC 5424 defines itself as v1 */
|
/* RFC 5424 defines itself as v1, notice space before time, c.f. RFC3164 */
|
||||||
snprintf(buffer->pribuf, sizeof(buffer->pribuf), "<%d>1", buffer->pri);
|
snprintf(buffer->pribuf, sizeof(buffer->pribuf), "<%d>1 ", buffer->pri);
|
||||||
pushiov(iov, i, buffer->pribuf);
|
pushiov(iov, i, buffer->pribuf);
|
||||||
pushsp(iov, i);
|
|
||||||
|
|
||||||
pushiov(iov, i, buffer->timebuf);
|
pushiov(iov, i, buffer->timebuf);
|
||||||
pushsp(iov, i);
|
pushsp(iov, i);
|
||||||
|
@ -223,7 +223,7 @@ struct logtime {
|
|||||||
/* message buffer container used for processing, formatting, and queueing */
|
/* message buffer container used for processing, formatting, and queueing */
|
||||||
struct buf_msg {
|
struct buf_msg {
|
||||||
int pri;
|
int pri;
|
||||||
char pribuf[7];
|
char pribuf[8];
|
||||||
int flags;
|
int flags;
|
||||||
struct logtime timestamp;
|
struct logtime timestamp;
|
||||||
char timebuf[33];
|
char timebuf[33];
|
||||||
|
Loading…
Reference in New Issue
Block a user