Mail archive
alpine-aports

Re: [alpine-aports] [PATCH] main/busybox: fix timezone adjustment in syslogd

From: Oleg Omelyusik <oleg.omelyusik_at_gmail.com>
Date: Mon, 24 Jul 2017 16:06:22 +0300

Hello,

No it wasn't, since timezone adjustment is Alpine specific feature.
This is about '-Z' option added to syslogd (commit
318c497f003be1645152235d1b08005f7dfde3ee in aports repo).
I've also found related open bug in your tracker and updated it:
https://bugs.alpinelinux.org/issues/3694

Thanks,
Oleg

On 24 July 2017 at 15:49, Natanael Copa <ncopa_at_alpinelinux.org> wrote:
> On Sat, 22 Jul 2017 01:23:42 +0300
> Oleg Omelyusik <oleg.omelyusik_at_gmail.com> wrote:
>
>> ---
>> ...gd-fix-timezone-adjustment-implementation.patch | 47 ++++++++++++++++++++++
>> main/busybox/APKBUILD | 2 +
>> 2 files changed, 49 insertions(+)
>> create mode 100644 main/busybox/0012-syslogd-fix-timezone-adjustment-implementation.patch
>>
>> diff --git a/main/busybox/0012-syslogd-fix-timezone-adjustment-implementation.patch b/main/busybox/0012-syslogd-fix-timezone-adjustment-implementation.patch
>> new file mode 100644
>> index 0000000000..f276bc3e57
>> --- /dev/null
>> +++ b/main/busybox/0012-syslogd-fix-timezone-adjustment-implementation.patch
>> _at_@ -0,0 +1,47 @@
>> +From b09a292755943b3881aa3525c906989929c19fc8 Mon Sep 17 00:00:00 2001
>> +From: Oleg Omelyusik <oleg.omelyusik_at_gmail.com>
>> +Date: Fri, 21 Jul 2017 16:29:55 +0300
>> +Subject: [PATCH] syslogd: fix timezone adjustment implementation
>> +
>> +strptime() does not set year value which is needed for mktime().
>> +Also need to take into account year value when operating with timestamps
>> +to prevent invalid convertions for leap years (e.g. Feb 28 23:00:00 UTC to GMT+2).
>
> Was this patch sent upstream?
>
> -nc
>
>> +---
>> + sysklogd/syslogd.c | 14 +++++++++++---
>> + 1 file changed, 11 insertions(+), 3 deletions(-)
>> +
>> +diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
>> +index 1c67d1379..5ad50acd0 100644
>> +--- a/sysklogd/syslogd.c
>> ++++ b/sysklogd/syslogd.c
>> +_at_@ -820,7 +820,8 @@ static void timestamp_and_log(int pri, char *msg, int len)
>> + {
>> + char *timestamp;
>> + time_t now;
>> +- struct tm nowtm = { .tm_isdst = 0 };
>> ++ struct tm msgtm = { .tm_isdst = 0 };
>> ++ struct tm nowtm = { 0 };
>> +
>> + /* Jan 18 00:11:22 msg... */
>> + /* 01234567890123456 */
>> +_at_@ -830,8 +831,15 @@ static void timestamp_and_log(int pri, char *msg, int len)
>> + now = time(NULL);
>> + timestamp = ctime(&now) + 4; /* skip day of week */
>> + } else {
>> +- if (G.adjustTimezone && strptime(msg, "%b %e %T", &nowtm)) {
>> +- now = mktime(&nowtm) - timezone;
>> ++ if (G.adjustTimezone && strptime(msg, "%b %e %T", &msgtm)) {
>> ++ /* set message year as current or previous year */
>> ++ now = time(NULL);
>> ++ gmtime_r(&now, &nowtm);
>> ++ msgtm.tm_year = nowtm.tm_year;
>> ++ if (nowtm.tm_mon < msgtm.tm_mon)
>> ++ --msgtm.tm_year;
>> ++ /* adjust message timestamp */
>> ++ now = mktime(&msgtm) - timezone;
>> + timestamp = ctime(&now) + 4; /* skip day of week */
>> + } else {
>> + now = 0;
>> +--
>> +2.13.0
>> +
>> diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
>> index 0010854105..e2d61f8799 100644
>> --- a/main/busybox/APKBUILD
>> +++ b/main/busybox/APKBUILD
>> _at_@ -29,6 +29,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
>> 0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
>> 0010-udhcpc-Don-t-background-if-n-is-given.patch
>> 0011-testsuite-fix-cpio-tests.patch
>> + 0012-syslogd-fix-timezone-adjustment-implementation.patch
>>
>> top-buffer-overflow.patch
>>
>> _at_@ -179,6 +180,7 @@ baac796f8aa96fbeab19f96eea7787ace5737b182f49e02f1b1e911d0a927ae14f3c334daad42418
>> d1c375184f806f7550bac5c82ab5471bdb8085d845172c973724b22af05ab3759b3ce982e088b4c45815ade56b9adfb7a677d0c180e077545ac7ec003c8aa7c4 0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
>> 9b5143d0be615b1604d82007628d59a62721f1e61a63cca7a4ffa5e60fa8da102bfc21fa20cc35c2f5a0a24bc8013598f8eff5888f9d0f3bcfa796343b5f5a91 0010-udhcpc-Don-t-background-if-n-is-given.patch
>> f4e00eb13fda752df13f300a7ed9b1320ca9f573c4309247f292c8710464d7be8740148f42e4aff16312335eadabce5a629dce4af58334b9199faf2fd658e4f9 0011-testsuite-fix-cpio-tests.patch
>> +e6774045441a88bf6b1edb83865cac33ee1a51c2da510b190cf6d790f1d2e6f13dc386c992ef414810dad7b80686f772b28adc5c25171bdc14cddc256344cdff 0012-syslogd-fix-timezone-adjustment-implementation.patch
>> 524e858b52cb31fb8d24e8c7f18606fff349aeab6a14da9cca3902641f6127980daed73c53586c6e8b41eecda06cdb29c40ff1dde2dc82a318c2649680458921 top-buffer-overflow.patch
>> a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c acpid.logrotate
>> 857dece10267a065e0e8c16dd6190656f890a5aff774e96321715673dda23e75a8e61148e81d6286b7bdfe737a0b99104f9b04deeb4f392c72b63d8e3d00e556 busyboxconfig
>


---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Mon Jul 24 2017 - 16:06:22 UTC