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,43 +945,46 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
|
|||||||
buffer.pri = pri;
|
buffer.pri = pri;
|
||||||
buffer.msg = line;
|
buffer.msg = line;
|
||||||
|
|
||||||
/* Parse the timestamp provided by the remote side. */
|
/*
|
||||||
if (strptime(msg, RFC3164_DATEFMT, &tm_parsed) !=
|
* Parse the TIMESTAMP provided by the remote side. If none is
|
||||||
msg + RFC3164_DATELEN || msg[RFC3164_DATELEN] != ' ') {
|
* found, assume this is not an RFC 3164 formatted message,
|
||||||
logit("Failed to parse TIMESTAMP from %s: %s\n", from, msg);
|
* only containing a TAG and a MSG.
|
||||||
return;
|
*/
|
||||||
}
|
if (strptime(msg, RFC3164_DATEFMT, &tm_parsed) ==
|
||||||
msg += RFC3164_DATELEN + 1;
|
msg + RFC3164_DATELEN && msg[RFC3164_DATELEN] == ' ') {
|
||||||
|
msg += RFC3164_DATELEN + 1;
|
||||||
|
|
||||||
if (!RemoteAddDate) {
|
if (!RemoteAddDate) {
|
||||||
struct tm tm_now;
|
struct tm tm_now;
|
||||||
time_t t_now;
|
time_t t_now;
|
||||||
int year;
|
int year;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As the timestamp does not contain the year number,
|
* As the timestamp does not contain the year
|
||||||
* daylight saving time information, nor a time zone,
|
* number, daylight saving time information, nor
|
||||||
* attempt to infer it. Due to clock skews, the
|
* a time zone, attempt to infer it. Due to
|
||||||
* timestamp may even be part of the next year. Use the
|
* clock skews, the timestamp may even be part
|
||||||
* last year for which the timestamp is at most one week
|
* of the next year. Use the last year for which
|
||||||
* in the future.
|
* 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);
|
t_now = time(NULL);
|
||||||
for (year = tm_now.tm_year + 1;; --year) {
|
localtime_r(&t_now, &tm_now);
|
||||||
assert(year >= tm_now.tm_year - 1);
|
for (year = tm_now.tm_year + 1;; --year) {
|
||||||
timestamp_remote.tm = tm_parsed;
|
assert(year >= tm_now.tm_year - 1);
|
||||||
timestamp_remote.tm.tm_year = year;
|
timestamp_remote.tm = tm_parsed;
|
||||||
timestamp_remote.tm.tm_isdst = -1;
|
timestamp_remote.tm.tm_year = year;
|
||||||
timestamp_remote.usec = 0;
|
timestamp_remote.tm.tm_isdst = -1;
|
||||||
if (mktime(×tamp_remote.tm) <
|
timestamp_remote.usec = 0;
|
||||||
t_now + 7 * 24 * 60 * 60)
|
if (mktime(×tamp_remote.tm) <
|
||||||
break;
|
t_now + 7 * 24 * 60 * 60)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer.timestamp = timestamp_remote;
|
||||||
}
|
}
|
||||||
buffer.timestamp = timestamp_remote;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user