diff options
author | Milan Crha <mcrha@redhat.com> | 2018-07-19 17:01:59 +0200 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2018-07-19 17:01:59 +0200 |
commit | 3761707d4e981b1ae6a77fc2065fb1750825465e (patch) | |
tree | cf95b90053e113e0136b8991519a30f78018c4c4 | |
parent | 990cb0333be4f736fb11608f7cf61d5598e09751 (diff) | |
download | evolution-data-server-3761707d4e981b1ae6a77fc2065fb1750825465e.tar.gz |
I#19 - Check also /var/db/zoneinfo when looking for system timezone
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/19
-rw-r--r-- | src/calendar/libecal/e-cal-system-timezone.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/calendar/libecal/e-cal-system-timezone.c b/src/calendar/libecal/e-cal-system-timezone.c index 022571c9d..b51f70e8d 100644 --- a/src/calendar/libecal/e-cal-system-timezone.c +++ b/src/calendar/libecal/e-cal-system-timezone.c @@ -35,6 +35,7 @@ #define ETC_SYSCONFIG_CLOCK "/etc/sysconfig/clock" #define ETC_CONF_D_CLOCK "/etc/conf.d/clock" #define ETC_LOCALTIME "/etc/localtime" +#define VAR_DB_ZONEINFO "/var/db/zoneinfo" #define TZ_MAGIC "TZif" @@ -66,7 +67,7 @@ system_timezone_strip_path_if_valid (const gchar *filename) /* Read the soft symlink from /etc/localtime */ static gchar * -system_timezone_read_etc_localtime_softlink (GHashTable *ical_zones) +system_timezone_read_etc_localtime_softlink (void) { gchar *file; gchar *tz; @@ -81,6 +82,24 @@ system_timezone_read_etc_localtime_softlink (GHashTable *ical_zones) return tz; } +/* Read from /var/db/zoneinfo, where tzsetup utility on FreeBSD stores the zone name */ +static gchar * +system_timezone_read_var_db_zoneinfo (void) +{ + gchar *tz = NULL; + + if (!g_file_get_contents (VAR_DB_ZONEINFO, &tz, NULL, NULL)) + return NULL; + + if (tz) + g_strchomp (tz); + + if (!tz || !*tz) + g_clear_pointer (&tz, g_free); + + return tz; +} + static gchar * system_timezone_read_etc_timezone (GHashTable *ical_zones) { @@ -546,7 +565,9 @@ system_timezone_find (void) } /* softlink is the best option, it points to the correct file */ - tz = system_timezone_read_etc_localtime_softlink (ical_zones); + tz = system_timezone_read_etc_localtime_softlink (); + if (!tz) + tz = system_timezone_read_var_db_zoneinfo (); if (system_timezone_is_valid (tz, ical_zones)) { g_hash_table_destroy (ical_zones); return tz; |