On Fri, Feb 22, 2019 at 10:44 AM Brian Adkins <[email protected]> wrote:

>
> Yes, I think we found the problem:
>
> $ ls -l /etc/localtime
> lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime ->
> /usr/share/zoneinfo/America/New_York
> deploy@ip-172-31-10-34:~$ ls -l /usr/share/zoneinfo/America/New_York
> lrwxrwxrwx 1 root root 13 Jan  1 00:05
> /usr/share/zoneinfo/America/New_York -> ../posixrules
>
>
> $ racket
> Welcome to Racket v7.1.
> > (require racket/enter)
> > (require tzinfo/private/zoneinfo)
> > (enter! tzinfo/private/zoneinfo)
> <pkgs>/tzinfo/tzinfo/private/zoneinfo> (define zi (make-zoneinfo-source))
> <pkgs>/tzinfo/tzinfo/private/zoneinfo> (tzinfo-has-tzid? zi
> "America/New_York")
> #t
> <pkgs>/tzinfo/tzinfo/private/zoneinfo> (find-zoneinfo-directory
> default-zoneinfo-search-path)
> "/usr/share/zoneinfo"
> <pkgs>/tzinfo/tzinfo/private/zoneinfo> (detect-tzid/unix (zoneinfo-dir zi)
>
>  (find-zoneinfo-directory default-zoneinfo-search-path)
>
>  (tzinfo->all-tzids zi))
> "posixrules"
>
>
Well, that's one I haven't seen before -- a file that actually names a time
zone is a symlink to another file. (I see we're not the only people who
have run afoul of this [https://github.com/HowardHinnant/date/issues/252]).

We have a few options here.
- Simply putting the /etc/timezone check before the /etc/localtime check
would solve the problem for you, though not for systems that use
/etc/localtime as a symlink but do not use /etc/timezone.
- Similarly, not short-circuiting the various checks and only looking for
valid values after we've accumulated all the results of the tests would
work in your case, assuming that (tzid-from-/etc/timezone) returns the
right answer for you (which I assume it does).
- Changing the implementation of the /etc/localtime check to use
readlink(2) to follow the symlink a single step is an option, though it
wouldn't help if someone linked directly from /etc/localtime to posixrules.
That sounds like a crazy scenario, but I would have said that linking
America/New_York to posixrules is unlikely. (I'd expect it to be the other
way around.) I guess the more general approach would be to use readlink(2)
until we find a path that names a time zone.
- I could also abandon the symlink check altogether and always use the slow
path, which checks for file _content_ identity between /etc/timezone and
any file that names an IANA time zone in the zoneinfo tree.

(Of course, all of this would be unnecessary if the tzid were actually
somewhere _in_ the tzfile(5) format somewhere.)

If you need an immediate workaround, you can launch racket with the TZ
environment variable set to the contents of /etc/timezone. But I'll fix
this just as soon as I decide what the best approach is.


By the way (and this question is for everyone), am I right that readlink(2)
functionality isn't already in the Racket standard library anywhere? (I
don't know if it has an analogue on Windows.)

 - Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to