diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-06-19 17:48:11 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-06-19 17:48:11 +0000 |
commit | 7b4d039e00b0e29f416c21a022ce2a6db23a4c30 (patch) | |
tree | b94bb63c1054ccf2b9f21999b23c52fa00bdaff3 | |
parent | 23633249c80c8ae886569058349e345d3a905bbc (diff) | |
download | upstream-7b4d039e00b0e29f416c21a022ce2a6db23a4c30.tar.gz upstream-7b4d039e00b0e29f416c21a022ce2a6db23a4c30.tar.bz2 upstream-7b4d039e00b0e29f416c21a022ce2a6db23a4c30.zip |
musl: read the timezone from /etc/TZ
Currently the OpenWRT boot scripts write the timezone configuration to
/tmp/TZ, relying on the behaviour of uClibc that the timezone is read
from /etc/TZ if no TZ env variable is found.
This works because /etc/TZ is a symlink to /tmp/TZ.
Musl libc however only reads the timezone from the TZ env variable and
if it doesn't find it or it's empty, it will look for a zoneinfo
file, that doesn't exist.
So in musl builds no timezone is ever set.
This patch fixes the issue by having musl libc behave like uClibc: if no
TZ env variable is found it will try to load it from /etc/TZ.
Signed-off-by: Gianluca Anzolin <gianluca at sottospazio.it>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 46069
-rw-r--r-- | toolchain/musl/patches/110-read_timezone_from_fs.patch | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/toolchain/musl/patches/110-read_timezone_from_fs.patch b/toolchain/musl/patches/110-read_timezone_from_fs.patch new file mode 100644 index 0000000000..3ff63ac220 --- /dev/null +++ b/toolchain/musl/patches/110-read_timezone_from_fs.patch @@ -0,0 +1,28 @@ +--- a/src/time/__tz.c ++++ b/src/time/__tz.c +@@ -23,6 +23,9 @@ static int r0[5], r1[5]; + static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end; + static size_t map_size; + ++static const char *tzfile; ++static size_t tzfile_size; ++ + static char old_tz_buf[32]; + static char *old_tz = old_tz_buf; + static size_t old_tz_size = sizeof old_tz_buf; +@@ -125,6 +128,15 @@ static void do_tzset() + "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0"; + + s = getenv("TZ"); ++ ++ /* if TZ is empty try to read it from /etc/TZ */ ++ if (!s || !*s) { ++ if (tzfile) ++ __munmap((void*)tzfile, tzfile_size); ++ ++ s = tzfile = (void *)__map_file("/etc/TZ", &tzfile_size); ++ } ++ + if (!s || !*s) s = "/etc/localtime"; + + if (old_tz && !strcmp(s, old_tz)) return; |