syslogd: Accept pre-RFC3164 formatted messages from remote hosts
This patch makes us wire-compatible with older versions of ourself, and current versions set up to use default remote format. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
06b26aae7b
commit
12fa1f6682
@ -945,12 +945,13 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
|
||||
buffer.pri = pri;
|
||||
buffer.msg = line;
|
||||
|
||||
/* Parse the timestamp provided by the remote side. */
|
||||
if (strptime(msg, RFC3164_DATEFMT, &tm_parsed) !=
|
||||
msg + RFC3164_DATELEN || msg[RFC3164_DATELEN] != ' ') {
|
||||
logit("Failed to parse TIMESTAMP from %s: %s\n", from, msg);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Parse the TIMESTAMP provided by the remote side. If none is
|
||||
* found, assume this is not an RFC 3164 formatted message,
|
||||
* only containing a TAG and a MSG.
|
||||
*/
|
||||
if (strptime(msg, RFC3164_DATEFMT, &tm_parsed) ==
|
||||
msg + RFC3164_DATELEN && msg[RFC3164_DATELEN] == ' ') {
|
||||
msg += RFC3164_DATELEN + 1;
|
||||
|
||||
if (!RemoteAddDate) {
|
||||
@ -959,15 +960,16 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
|
||||
int year;
|
||||
|
||||
/*
|
||||
* As the timestamp does not contain the year number,
|
||||
* daylight saving time information, nor a time zone,
|
||||
* attempt to infer it. Due to clock skews, the
|
||||
* timestamp may even be part of the next year. Use the
|
||||
* last year for which the timestamp is at most one week
|
||||
* in the future.
|
||||
* As the timestamp does not contain the year
|
||||
* number, daylight saving time information, nor
|
||||
* a time zone, attempt to infer it. Due to
|
||||
* clock skews, the timestamp may even be part
|
||||
* of the next year. Use the last year for which
|
||||
* the timestamp is at most one week in the
|
||||
* future.
|
||||
*
|
||||
* This loop can only run for at most three iterations
|
||||
* before terminating.
|
||||
* This loop can only run for at most three
|
||||
* iterations before terminating.
|
||||
*/
|
||||
t_now = time(NULL);
|
||||
localtime_r(&t_now, &tm_now);
|
||||
@ -983,6 +985,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
|
||||
}
|
||||
buffer.timestamp = timestamp_remote;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A single space character MUST also follow the HOSTNAME field.
|
||||
|
Loading…
Reference in New Issue
Block a user