[OpenWrt-Devel] musl libc and timezone

John Crispin blogic at openwrt.org
Wed Nov 19 02:24:49 EST 2014



On 18/11/2014 10:54, Gianluca Anzolin wrote:
> Hi,
> 
> I'm experimenting with the musl libc build, and I'm quite satisfied.
> 
> One thing that still bothers me is that the timezone is not working.
> 
> Currently the boot scripts in OpenWRT parse /etc/config/system and save the
> timezone in /tmp/TZ.
> 
> The code in uClibc looks for a TZ variable in the environment and if it doesn't
> find it, it tries to read /etc/TZ, a symlink that points to /tmp/TZ and
> everything works.
> 
> Musl libc however doesn't work this way: it doesn't try to load /etc/TZ.
> It looks for a TZ env variable and if it doesn't find it, it resorts to
> canonical zoneinfo files. The timezone in /tmp/TZ is ignored.
> 
> I cooked up a patch to make musl libc read the /etc/TZ file, however I don't
> think this is an efficient solution since it resorts to read data from the
> filesystem. A simpler getenv("TZ") wouldn't need to access the fs at all.
> 
> So in my opinion the "better" fix would be to populate the TZ environment
> variable.
> 

so if a process is spawned and thent he TZ changes the process is stuck
on the old TZ ? that seems totally broken

	John







> With the current setup I simply added the following line to /etc/profile:
> 
> [ -f /tmp/TZ ] && export TZ=$(cat /tmp/TZ)
> 
> and now date returns the correct time and timezone.
> 
> I however suspect that this fix doesn't work with processes started by procd,
> actually I haven't had the time to check.
> 
> If that is the case, would there be a way to populate the TZ env variable also
> for those processes?
> 
> Thank you,
> 
> Gianluca
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list