Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local timezone check doesn't follow symlinks #33

Open
drinckes opened this issue Jun 8, 2023 · 1 comment
Open

Local timezone check doesn't follow symlinks #33

drinckes opened this issue Jun 8, 2023 · 1 comment

Comments

@drinckes
Copy link

drinckes commented Jun 8, 2023

_load_local_tzinfo() loads timezone files from /usr/share/zoneinfo/posix, and uses os.walk() to list the files.

But by default os.walk doesn't follow symlinks, so if the timezone files in /usr/share/zoneinfo/posix are symlinks to other locations (which doesn't seem terribly rare), those files won't be read in.

This can result in failing to load a timezone that matches /etc/timezone.

@drinckes
Copy link
Author

drinckes commented Jun 8, 2023

One possible solution is to add the follow_symlinks=True as a parameter to os.walk, accepting the risk that this might never complete on it's own as os.walk doesn't track the directories it visits.

https://docs.python.org/3/library/os.html#os.walk

Note Be aware that setting followlinks to True can lead to infinite recursion if a link points to a parent directory of itself. walk() does not keep track of the directories it visited already.

Python documentation
Source code: Lib/os.py This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, s...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant