mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Handling of non-location specific TZ values
@ 2021-04-25 17:46 Sören Tempel
  2021-04-25 18:38 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Sören Tempel @ 2021-04-25 17:46 UTC (permalink / raw)
  To: musl

Hi,

While debugging a test failure of the calendar application calcurse on
Alpine I noticed that musl does not support TZ values which don't
include area/location information, e.g. TZ=CET [0]. This is contrary to
the documentation from the musl wiki which states the following [1]:

	The zoneinfo file is interpreted as an absolute pathname if it
	begins with a slash, a relative pathname if it begins with a
	dot, and otherwise is searched in /usr/share/zoneinfo,
	/share/zoneinfo, and /etc/zoneinfo.

Since commit 5c4f11d995cf178b3146cde0734d6988c145f243 musl only consults
the zoneinfo database if the value of the TZ environment variable starts
with a colon or contains a slash [2]. As such, the zoneinfo database is
not consulted for TZ=CET thereby causing musl to not determine DST etc.
correctly for such TZ values. TZ values such as Europe/Kaliningrad are
correctly looked up in the zoneinfo database though.

The aforementioned commit claims that this strict check is necessary
since "TZ=name is reserved for POSIX-form" which consists of a mandatory
timezone name (std), an offset, and some more optional information [3].
**If** TZ values adhering to the POSIX format should not be looked up in
the zoneinfo database, it would be necessary to somehow determine if a
given string adheres to the POSIX timezone format before performing the
lookup.

The glibc implementation seems to unconditionally consult the zoneinfo
database and falls back to the POSIX format (__tzset_parse_tz) if no
corresponding file was found in the database [4]. Apart from glibc, the
non-POSIX TZ format with TZ=<timezone> is also supported BSDs, e.g.
OpenBSD [5].

Any thoughts on how this could fixed in musl?

Greetings,
Sören

[0]: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/19695
[1]: https://wiki.musl-libc.org/environment-variables.html
[2]: https://git.musl-libc.org/cgit/musl/commit/?id=5c4f11d995cf178b3146cde0734d6988c145f243
[3]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
[4]: https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=2fc51194b63bda8eeaff4f2ac111291ff43c28ad;hb=24f261f27fb8fd19ae294ff2a13bc5b7a0bafc91#l405
[5]: https://github.com/openbsd/src/blob/2207c4325726fdc5c4bcd0011af0fdf7d3dab137/lib/libc/time/Theory

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-05 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-25 17:46 [musl] Handling of non-location specific TZ values Sören Tempel
2021-04-25 18:38 ` Rich Felker
2021-05-02 20:28   ` Sören Tempel
2021-06-02 15:41     ` Sören Tempel
2021-06-05 15:52       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).