Bug 217317
Summary: | localtime() doesn't cache /etc/localtime contents, gets confused following chroot() | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Philip Prindeville <philipp> | ||||
Component: | glibc | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | Brian Brock <bbrock> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 5 | CC: | drepper | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2006-11-27 09:52:58 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Philip Prindeville
2006-11-27 00:01:47 UTC
Created attachment 142142 [details]
Sample test program.
Most of this is documented already in POSIX. The "hook to prefetch /etc/localtime" is called tzset(3p), then there are several functions which just use the timezone data (these do effectively an tzset only if it hasn't been called yet in the current process, ctime is one of them) and then other function where their 3p section man pages mention that they behave as if they use tzset internally (e.g. localtime, these functions really do that). If TZ env var is unset, tzset stats /etc/localtime and if it was called the first time or if it changed since last call (this was added so that changing timezone on a running system is possible without restarting everything), it is reread (and if /etc/localtime is not valid, the default is TZ=GMT). So, when using the chroot, preferrably link or bind mount /etc/localtime into the chroot (e.g. system-config-date and /usr/sbin/tzdata-update copy /etc/localtime over to /var/spool/postfix/etc/localtime if it existed previously and had the same content as /etc/localtime), or tzset () before chrooting and make sure you don't use any functions where documentation says it behaves as if tzset () was called. Ok, does localtime_r() behave like localtime() in this respect? Does ctime_r() behave local ctime()? And does openlog() call tzset() to make itself chroot()-safe? If not, it might be worth changing it so that it does. But I guess the more important issue, is that when it is called repeatedly (as happens in glibc's syslog() -- since it calls localtime_r() and strftime_r()), should it be idempotent? If you call it outside the chroot() prison, and tzset() succeeds, then you chroot() and call it again and it fails to find its files... should failing cause it to clobber the previously good results it had from before? Seems self-defeating. |