diff options
Diffstat (limited to 'main/busybox')
-rw-r--r-- | main/busybox/0015-syslogd-adjust-timezone-option.patch | 105 | ||||
-rw-r--r-- | main/busybox/APKBUILD | 4 |
2 files changed, 108 insertions, 1 deletions
diff --git a/main/busybox/0015-syslogd-adjust-timezone-option.patch b/main/busybox/0015-syslogd-adjust-timezone-option.patch new file mode 100644 index 0000000000..ba2b9aae42 --- /dev/null +++ b/main/busybox/0015-syslogd-adjust-timezone-option.patch @@ -0,0 +1,105 @@ +From 97577835169acc9ee8ef25b0561cbfaa78463f5c Mon Sep 17 00:00:00 2001 +From: Shiz <hi@shiz.me> +Date: Mon, 8 May 2017 23:09:13 +0200 +Subject: [PATCH] sysklogd: add -Z option to adjust message timezones + +Some syslog() implementations like musl's[1] always send timestamps in UTC. +This change adds a new option to syslogd, -Z, to assume incoming timestamps +are always UTC and adjust them to the local timezone (of the syslogd) before +logging. + +[1]: http://www.openwall.com/lists/musl/2014/01/29/1 + +Signed-off-by: Shiz <hi@shiz.me> +--- + sysklogd/syslogd.c | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c +index d64ff27..159336e 100644 +--- a/sysklogd/syslogd.c ++++ b/sysklogd/syslogd.c +@@ -122,6 +122,7 @@ + //usage: "(this version of syslogd ignores /etc/syslog.conf)\n" + //usage: ) + //usage: "\n -n Run in foreground" ++//usage: "\n -Z Adjust incoming UTC times to local time" + //usage: IF_FEATURE_REMOTE_LOG( + //usage: "\n -R HOST[:PORT] Log to HOST:PORT (default PORT:514)" + //usage: "\n -L Log locally and via network (default is network only if -R)" +@@ -233,6 +234,8 @@ typedef struct logRule_t { + /*int markInterval;*/ \ + /* level of messages to be logged */ \ + int logLevel; \ ++ /* whether to adjust message timezone */\ ++ int adjustTimezone; \ + IF_FEATURE_ROTATE_LOGFILE( \ + /* max size of file before rotation */ \ + unsigned logFileSize; \ +@@ -316,6 +319,7 @@ enum { + OPTBIT_outfile, // -O + OPTBIT_loglevel, // -l + OPTBIT_small, // -S ++ OPTBIT_adjusttz, // -Z + IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s + IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b + IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R +@@ -330,6 +334,7 @@ enum { + OPT_outfile = 1 << OPTBIT_outfile , + OPT_loglevel = 1 << OPTBIT_loglevel, + OPT_small = 1 << OPTBIT_small , ++ OPT_adjusttz = 1 << OPTBIT_adjusttz, + OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0, + OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0, + OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0, +@@ -339,7 +344,7 @@ enum { + OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0, + OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0, + }; +-#define OPTION_STR "m:nO:l:S" \ ++#define OPTION_STR "m:nO:l:SZ" \ + IF_FEATURE_ROTATE_LOGFILE("s:" ) \ + IF_FEATURE_ROTATE_LOGFILE("b:" ) \ + IF_FEATURE_REMOTE_LOG( "R:*") \ +@@ -815,17 +820,23 @@ static void timestamp_and_log(int pri, char *msg, int len) + { + char *timestamp; + time_t now; ++ struct tm nowtm = { .tm_isdst = 0 }; + + /* Jan 18 00:11:22 msg... */ + /* 01234567890123456 */ + if (len < 16 || msg[3] != ' ' || msg[6] != ' ' + || msg[9] != ':' || msg[12] != ':' || msg[15] != ' ' + ) { +- time(&now); ++ now = time(NULL); + timestamp = ctime(&now) + 4; /* skip day of week */ + } else { +- now = 0; +- timestamp = msg; ++ if (G.adjustTimezone && strptime(msg, "%b %e %T", &nowtm)) { ++ now = mktime(&nowtm) - timezone; ++ timestamp = ctime(&now) + 4; /* skip day of week */ ++ } else { ++ now = 0; ++ timestamp = msg; ++ } + msg += 16; + } + timestamp[15] = '\0'; +@@ -1130,6 +1141,10 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv) + if (opts & OPT_loglevel) // -l + G.logLevel = xatou_range(opt_l, 1, 8); + //if (opts & OPT_small) // -S ++ if (opts & OPT_adjusttz) { // -Z ++ G.adjustTimezone = 1; ++ tzset(); ++ } + #if ENABLE_FEATURE_ROTATE_LOGFILE + if (opts & OPT_filesize) // -s + G.logFileSize = xatou_range(opt_s, 0, INT_MAX/1024) * 1024; +-- +2.10.0 + + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index 10897726a0..2667b273f7 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=busybox pkgver=1.26.2 -pkgrel=2 +pkgrel=3 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -30,6 +30,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 0012-diff-add-support-for-no-dereference.patch 0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch 0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch + 0015-syslogd-adjust-timezone-option.patch fix-tests.patch location-for-cpio.patch @@ -162,6 +163,7 @@ f82caa1dc4395f266b024a7face267a916a80ead95f3d392b10fd397d0fdf62703e3078357bc7196 361959788bc11b7f20d4029bb0f561759d270983b09c44fe2a01817378c4eb1c98cd8ef73e7ef8c168b7540170f58ddb36b9e4f80a97565f3fe3ba85b593a471 0012-diff-add-support-for-no-dereference.patch bf3e7c400e718fbc19fda19d7304ed938e5c59f45d5d1ba6eafd8f62a984d40419dbefd9f6840ac7f220d00abfae67e8f31be78b4c2e25310b265bca8beb91a2 0013-ash-make-shellexec-capable-of-using-separate-argv-0-.patch cb7aa4d5d22596bc8c6510cb653599dd8cf4c3a5312e93adfc6411d811376db2ad3b506a111322f46aa9929a5337e22a169da4ea250fd4b39e703adbc8792a2d 0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch +c37d1583cfb32e7aa077e7f4ea121dd3b2e3cf989a3dca2793126bcd89eb6d8eb6fae948085565807c2fb98d8dc92a2907cc03d988d1a47305d3e588ac268c5b 0015-syslogd-adjust-timezone-option.patch 2adfc6c71cfcc5df12edef13228c92b34c7782615e60effc97e6e7a9aa7e015c24c7b3950a8a9a2bf3ba5efd43a08ad45b16b35b03c90275807380e0600cb70d fix-tests.patch f26e090f5de0096ba5c4d46989ebe0ab5fa64c8bf54cd37ddec302fddfde23eac914858d86cc52bf3b5780a8e81ea2612ef6e713df2828e52c606f86a6816f39 location-for-cpio.patch a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c acpid.logrotate |