From 6a71dd03e3d5c2eecdf6d6fcae50ab53656ff148 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 26 Nov 2014 17:38:40 +0100 Subject: Resolve relative symlink of /etc/localtime This fixes wrong detection of system timezone under certain circumstances. Example: in Fedora 20, the environment is a follows: a) /etc/localtime symlinks --> ../usr/share/zoneinfo/Europe/Zurich b) /usr/share/zoneinfo contains files with more than 1 hardlink. In example, Europe/Zurich and Europe/Vaduz share the same i-node. - system_timezone_read_etc_localtime_softlink() because the link is relative. - The next algorithms fail because the targeted files do not exist. - system_timezone_read_etc_localtime_hardlink() succeeds, but finds Europe/Vaduz before Europe/Zurich. Thus the detected system timezone is wrong. By resolving a relative /etc/localtime symlink, this patch leads algorithm system_timezone_read_etc_localtime_softlink() to success and therefore proper detection of system timezone. Closes https://patch-diff.githubusercontent.com/raw/mate-desktop/mate-panel/pull/261.patch --- applets/clock/system-timezone.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'applets/clock') diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c index 28b3525b..525921c1 100644 --- a/applets/clock/system-timezone.c +++ b/applets/clock/system-timezone.c @@ -634,6 +634,22 @@ system_timezone_read_etc_localtime_softlink (void) return NULL; file = g_file_read_link (ETC_LOCALTIME, NULL); + + if (*file != '/') { + GFile *gf1; + GFile *gf2; + + /* Resolve relative path. */ + gf1 = g_file_new_for_path (ETC_LOCALTIME); + gf2 = g_file_get_parent (gf1); + g_object_unref (gf1); + gf1 = g_file_resolve_relative_path (gf2, file); + g_object_unref (gf2); + g_free (file); + file = g_file_get_path (gf1); + g_object_unref (gf1); + } + tz = system_timezone_strip_path_if_valid (file); g_free (file); -- cgit v1.2.1