[asterisk-bugs] [Asterisk 0014300]: [patch] zoneinfo caching causes incorrect time
Asterisk Bug Tracker
noreply at bugs.digium.com
Wed Jan 21 14:49:45 CST 2009
The following issue requires your FEEDBACK.
======================================================================
http://bugs.digium.com/view.php?id=14300
======================================================================
Reported By: jamessan
Assigned To:
======================================================================
Project: Asterisk
Issue ID: 14300
Category: Core/General
Reproducibility: always
Severity: minor
Priority: normal
Status: feedback
Asterisk Version: 1.4.22
Regression: No
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2009-01-21 14:05 CST
Last Modified: 2009-01-21 14:49 CST
======================================================================
Summary: [patch] zoneinfo caching causes incorrect time
Description:
In stdtime/localtime.c, the information for time-zones are cached in a
state struct. This caching is keyed off the name of the zone passed into
ast_tzset (using /etc/localtime if none is provided).
This is problematic since it isn't uncommon for the localtime file to be a
symlink to/copy of the actual zoneinfo file. Therefore, if the target of
the symlink is changed to affect a change in the system's timezone,
Asterisk will not recognize the change until it is restarted.
The attached patch uses realpath(3) to attempt expanding the zone to a
full path and using that as the key instead. This will ensure that if a
path like "/etc/localtime" or "/usr/share/zoneinfo/localtime" is being used
and is a symlink, changes in the target of the symlink will cause the
zoneinfo to be updated.
The limitations of this patch are:
1) Only notices changes when symlinks are used. If "/etc/localtime" (or
whatever the common file is) is a copy/hardlink instead, changes won't be
noticed. Making use of lstat(2) instead of realpath(3) may be an approach
to consider.
2) It doesn't handle the condition where zone is passed to ast_tzset and
is using a relative path and/or the zone contains a leading colon. There's
code in tzload that determines the absolute path which could be pulled out
into a common function. Feeding the results of that into realpath(3) would
then handle the different formats that the zone could be specified in.
======================================================================
----------------------------------------------------------------------
(0098350) Corydon76 (administrator) - 2009-01-21 14:49
http://bugs.digium.com/view.php?id=14300#c98350
----------------------------------------------------------------------
I see your point, but I have a couple of comments:
1) Changing the timezone typically only occurs at system setup and never
thereafter. This would thus be extra code that isn't otherwise necessary.
Therefore, I don't think this is appropriate for anything other than
trunk.
2) The manpage for realpath(3) notes that it is broken by design, since it
does not take the length of a buffer as a parameter, and thus is prone to
buffer overflows. readlink(2) is probably preferable.
Issue History
Date Modified Username Field Change
======================================================================
2009-01-21 14:49 Corydon76 Note Added: 0098350
2009-01-21 14:49 Corydon76 Status new => feedback
======================================================================
More information about the asterisk-bugs
mailing list