[evolution-data-server] I#19 - Check also /var/db/zoneinfo when looking for system timezone



commit 3761707d4e981b1ae6a77fc2065fb1750825465e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jul 19 17:01:59 2018 +0200

    I#19 - Check also /var/db/zoneinfo when looking for system timezone
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/19

 src/calendar/libecal/e-cal-system-timezone.c | 25 +++++++++++++++++++++++--
 1 file 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]