aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysklogd/syslogd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 4265f4f90..5630d97fc 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -140,6 +140,7 @@
140//usage: ) 140//usage: )
141//usage: "\n -l N Log only messages more urgent than prio N (1-8)" 141//usage: "\n -l N Log only messages more urgent than prio N (1-8)"
142//usage: "\n -S Smaller output" 142//usage: "\n -S Smaller output"
143//usage: "\n -t Strip client-generated timestamps"
143//usage: IF_FEATURE_SYSLOGD_DUP( 144//usage: IF_FEATURE_SYSLOGD_DUP(
144//usage: "\n -D Drop duplicates" 145//usage: "\n -D Drop duplicates"
145//usage: ) 146//usage: )
@@ -316,6 +317,7 @@ enum {
316 OPTBIT_outfile, // -O 317 OPTBIT_outfile, // -O
317 OPTBIT_loglevel, // -l 318 OPTBIT_loglevel, // -l
318 OPTBIT_small, // -S 319 OPTBIT_small, // -S
320 OPTBIT_timestamp, // -t
319 IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s 321 IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s
320 IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b 322 IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b
321 IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R 323 IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R
@@ -330,6 +332,7 @@ enum {
330 OPT_outfile = 1 << OPTBIT_outfile , 332 OPT_outfile = 1 << OPTBIT_outfile ,
331 OPT_loglevel = 1 << OPTBIT_loglevel, 333 OPT_loglevel = 1 << OPTBIT_loglevel,
332 OPT_small = 1 << OPTBIT_small , 334 OPT_small = 1 << OPTBIT_small ,
335 OPT_timestamp = 1 << OPTBIT_timestamp,
333 OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0, 336 OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0,
334 OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0, 337 OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0,
335 OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0, 338 OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0,
@@ -339,7 +342,7 @@ enum {
339 OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0, 342 OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
340 OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0, 343 OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0,
341}; 344};
342#define OPTION_STR "m:nO:l:S" \ 345#define OPTION_STR "m:nO:l:St" \
343 IF_FEATURE_ROTATE_LOGFILE("s:" ) \ 346 IF_FEATURE_ROTATE_LOGFILE("s:" ) \
344 IF_FEATURE_ROTATE_LOGFILE("b:" ) \ 347 IF_FEATURE_ROTATE_LOGFILE("b:" ) \
345 IF_FEATURE_REMOTE_LOG( "R:*") \ 348 IF_FEATURE_REMOTE_LOG( "R:*") \
@@ -813,21 +816,27 @@ static void parse_fac_prio_20(int pri, char *res20)
813 * that there is no timestamp, short-circuiting the test. */ 816 * that there is no timestamp, short-circuiting the test. */
814static void timestamp_and_log(int pri, char *msg, int len) 817static void timestamp_and_log(int pri, char *msg, int len)
815{ 818{
816 char *timestamp; 819 char *timestamp = NULL;
817 time_t now; 820 time_t now;
818 821
819 /* Jan 18 00:11:22 msg... */ 822 /* Jan 18 00:11:22 msg... */
820 /* 01234567890123456 */ 823 /* 01234567890123456 */
821 if (len < 16 || msg[3] != ' ' || msg[6] != ' ' 824 if (len >= 16 && msg[3] == ' ' && msg[6] == ' '
822 || msg[9] != ':' || msg[12] != ':' || msg[15] != ' ' 825 && msg[9] == ':' && msg[12] == ':' && msg[15] == ' '
823 ) { 826 ) {
827 if (!(option_mask32 & OPT_timestamp)) {
828 /* use message timestamp */
829 timestamp = msg;
830 now = 0;
831 }
832 msg += 16;
833 }
834
835 if (!timestamp) {
824 time(&now); 836 time(&now);
825 timestamp = ctime(&now) + 4; /* skip day of week */ 837 timestamp = ctime(&now) + 4; /* skip day of week */
826 } else {
827 now = 0;
828 timestamp = msg;
829 msg += 16;
830 } 838 }
839
831 timestamp[15] = '\0'; 840 timestamp[15] = '\0';
832 841
833 if (option_mask32 & OPT_kmsg) { 842 if (option_mask32 & OPT_kmsg) {