110-read_timezone_from_fs.patch 748 B

12345678910111213141516171819202122232425262728
  1. --- a/src/time/__tz.c
  2. +++ b/src/time/__tz.c
  3. @@ -23,6 +23,9 @@ static int r0[5], r1[5];
  4. static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end;
  5. static size_t map_size;
  6. +static const char *tzfile;
  7. +static size_t tzfile_size;
  8. +
  9. static char old_tz_buf[32];
  10. static char *old_tz = old_tz_buf;
  11. static size_t old_tz_size = sizeof old_tz_buf;
  12. @@ -125,6 +128,15 @@ static void do_tzset()
  13. "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
  14. s = getenv("TZ");
  15. +
  16. + /* if TZ is empty try to read it from /etc/TZ */
  17. + if (!s || !*s) {
  18. + if (tzfile)
  19. + __munmap((void*)tzfile, tzfile_size);
  20. +
  21. + s = tzfile = (void *)__map_file("/etc/TZ", &tzfile_size);
  22. + }
  23. +
  24. if (!s) s = "/etc/localtime";
  25. if (!*s) s = __gmt;