Bug 1236667

Summary: RHEL 6 does not provide a canonical way of obtaining the timezone (/etc/timezone)
Product: Red Hat Enterprise Linux 6 Reporter: Andrew John Hughes <ahughes>
Component: system-config-dateAssignee: Jan Synacek <jsynacek>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: ahughes, jsynacek, nphilipp, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-15 09:10:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrew John Hughes 2015-06-29 16:51:58 UTC
OpenJDK needs to obtain the currently selected timezone in order to provide an appropriate default timezone from Java.

It tries a number of methods to obtain this, but, as can be seen from bug 489586 and bug 995488, none of them are ideal:

1. /etc/sysconfig/clock is checked, but this runs into issues where the zone ID is changed to include spaces (e.g. "America/New York" instead of "America/New_York"). Support was removed in bug 489586, but then had to be reinstated in bug 995488 as there was no way to differentiate between zones with the same data but a different ID. We're now hitting 489586 again; see bug 1236619.

2. If /etc/localtime is a symlink, this is followed to find the actual timezone file and thus its name. This seems to be the case on RHEL 7, but not 6.

3. /etc/localtime is compared to the files in /usr/share/zoneinfo, but there can be multiple matches (bug 995488).

In discussing bug 995488, we were told that both #1 and #2 are unsupported and /etc/sysconfig/clock had no guaranteed format, being for the use of system-config-date only. It was proposed then that /etc/timezone was introduced, which is the method used on Debian-based systems and is supported upstream by OpenJDK (and thus by the proprietary Oracle JDKs too). However, nothing was done to make this happen and the hack for /etc/sysconfig/clock was simply added back into OpenJDK, regressing bug 489586.

So I'm again proposing that /etc/timezone is provided on RHEL. It's a simple text file containing the zone name as it exists in /usr/share/zoneinfo e.g.

$ cat /etc/timezone 
America/New_York

It's simpler to parse than /etc/sysconfig/clock and not subject to the varying versions that are floating around.

Alternatively, I'm open to other suggestions, but they are likely to require work to get the changes into upstream OpenJDK and thus may never be supported on some older versions.

Comment 3 Andrew John Hughes 2015-08-26 16:09:32 UTC
Any news on this?

Comment 11 Jan Synacek 2016-09-15 09:10:19 UTC
(In reply to Andrew John Hughes from comment #0)
> OpenJDK needs to obtain the currently selected timezone in order to provide
> an appropriate default timezone from Java.

I wonder... How do other applications on RHEL6 do it? Isn't there a way to parse the raw /etc/localtime?

> 1. /etc/sysconfig/clock is checked, but this runs into issues where the zone
> ID is changed to include spaces (e.g. "America/New York" instead of
> "America/New_York"). Support was removed in bug 489586, but then had to be
> reinstated in bug 995488 as there was no way to differentiate between zones
> with the same data but a different ID. We're now hitting 489586 again; see
> bug 1236619.

This will be fixed, see https://bugzilla.redhat.com/show_bug.cgi?id=956284.

> 2. If /etc/localtime is a symlink, this is followed to find the actual
> timezone file and thus its name. This seems to be the case on RHEL 7, but
> not 6.

Yes, that's a problem and I guess it should be a symlink. I'd rather not change it, though, as it would potentially be a big change and it's quite late for that in RHEL6.

> So I'm again proposing that /etc/timezone is provided on RHEL. It's a simple
> text file containing the zone name as it exists in /usr/share/zoneinfo e.g.

This would not improve anything if there's basically the same information as in /etc/sysconfig/clock. Also, /etc/timezone is *not* present/supported on RHEL7, therefore, I don't want to introduce it, as it would automatically mean a regression there.

> It's simpler to parse than /etc/sysconfig/clock and not subject to the
> varying versions that are floating around.

What versions? Floating where? I thought there was only one version on RHEL6.

> Alternatively, I'm open to other suggestions, but they are likely to require
> work to get the changes into upstream OpenJDK and thus may never be
> supported on some older versions.

Since there are already workarounds present in OpenJDK that are basically RHEL6 only, I'm closing this bug.