[asterisk-bugs] [Asterisk 0014300]: [patch] zoneinfo caching causes incorrect time

Asterisk Bug Tracker noreply at bugs.digium.com
Wed Feb 25 13:25:03 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14300 
====================================================================== 
Reported By:                jamessan
Assigned To:                tilghman
====================================================================== 
Project:                    Asterisk
Issue ID:                   14300
Category:                   Core/General
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
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-02-25 13:25 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.
====================================================================== 

---------------------------------------------------------------------- 
 (0100742) svnbot (reporter) - 2009-02-25 13:25
 http://bugs.digium.com/view.php?id=14300#c100742 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 178605

U   trunk/configure
U   trunk/configure.ac
U   trunk/include/asterisk/autoconfig.h.in
U   trunk/main/stdtime/localtime.c

------------------------------------------------------------------------
r178605 | tilghman | 2009-02-25 13:25:02 -0600 (Wed, 25 Feb 2009) | 9
lines

Use notification when timezone files change and re-scan then.
(closes issue http://bugs.digium.com/view.php?id=14300)
 Reported by: jamessan
 Patches: 
       20090127__bug14300.diff.txt uploaded by tilghman (license 14)
       20090224__bug14300.diff uploaded by jamessan (license 246)
 Tested by: jamessan
 Review: http://reviewboard.digium.com/r/136/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=178605 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-02-25 13:25 svnbot         Checkin                                      
2009-02-25 13:25 svnbot         Note Added: 0100742                          
======================================================================




More information about the asterisk-bugs mailing list