summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Monnerat <[email protected]>2014-11-26 17:38:40 +0100
committerStefano Karapetsas <[email protected]>2015-04-09 20:34:41 +0200
commit6a71dd03e3d5c2eecdf6d6fcae50ab53656ff148 (patch)
tree580ebd3124922b754b5882819b605f63c9ddc176
parente6a14da0f7946f77e4316a05e051527b54ec1c99 (diff)
downloadmate-panel-6a71dd03e3d5c2eecdf6d6fcae50ab53656ff148.tar.bz2
mate-panel-6a71dd03e3d5c2eecdf6d6fcae50ab53656ff148.tar.xz
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
-rw-r--r--applets/clock/system-timezone.c16
1 files changed, 16 insertions, 0 deletions
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);