Mercurial > hg > release > icedtea7-forest-2.3 > jdk
changeset 6322:5dc47fef62d0
RH995488: Java thinks that the default timezone is Busingen instead of Zurich
author | andrew |
---|---|
date | Fri, 06 Sep 2013 12:45:39 +0100 |
parents | 5bbb4c34cc3a |
children | 424d6404dab6 |
files | src/solaris/native/java/util/TimeZone_md.c |
diffstat | 1 files changed, 60 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/solaris/native/java/util/TimeZone_md.c Fri Sep 06 12:44:40 2013 +0100 +++ b/src/solaris/native/java/util/TimeZone_md.c Fri Sep 06 12:45:39 2013 +0100 @@ -53,6 +53,8 @@ static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; +static const char *REDHAT_RELEASE_FILE = "/etc/redhat-release"; +static const char *SYSCONFIG_CLOCK_FILE = "/etc/sysconfig/clock"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime"; #else @@ -255,6 +257,64 @@ #endif /* __linux__ */ /* + * Next, try the ZONE entry in /etc/sysconfig/clock. + */ + if ((fp = fopen(REDHAT_RELEASE_FILE, "r")) != NULL) { + char id[7]; + + /* Avoid this file on Fedora as may be buggy; RH489586 */ + if (fgets(id, sizeof (id), fp) != NULL && + strncmp(id, "Fedora", 6) != 0) { + (void) fclose(fp); + if ((fp = fopen(SYSCONFIG_CLOCK_FILE, "r")) != NULL) { + char line[256]; + + while (fgets(line, sizeof(line), fp) != NULL) { + char *p = line; + char *s; + + SKIP_SPACE(p); + if (*p != 'Z') { + continue; + } + if (strncmp(p, "ZONE=\"", 6) == 0) { + p += 6; + } else { + /* + * In case we need to parse it token by token. + */ + if (strncmp(p, "ZONE", 4) != 0) { + continue; + } + p += 4; + SKIP_SPACE(p); + if (*p++ != '=') { + break; + } + SKIP_SPACE(p); + if (*p++ != '"') { + break; + } + } + for (s = p; *s && *s != '"'; s++) + ; + if (*s != '"') { + /* this ZONE entry is broken. */ + break; + } + *s = '\0'; + tz = strdup(p); + break; + } + (void) fclose(fp); + if (tz != NULL) { + return tz; + } + } + } + } + + /* * Next, try /etc/localtime to find the zone ID. */ if (lstat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) {