summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2022-10-24 12:35:29 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2022-10-24 12:35:29 +0100
commitf8c80391ae2b47e7bc83bdd582cbd44b131f61a0 (patch)
treeb19547bde5d2e571a3270fc9b4a87a3414f6238c
parent662661a8d0e1debefccb9ec5b204668bf59d140c (diff)
downloadglib-f8c80391ae2b47e7bc83bdd582cbd44b131f61a0.tar.gz
gtimezone: Fix symlink checks on relative link targets
The changes in 6265b2e6f70d6f0ec4d16adcdc5f7c53aecf0da4 to reject weird `/etc/localtime` configurations where `/etc/localtime` links to another symlink did not consider the case where the target of `/etc/localtime` is a *relative* path. They only considered the case where the target is absolute. Relative paths are permissible in all symlinks. On my Fedora 36 system, `/etc/localtime`’s target is `../usr/share/zoneinfo/Europe/London`. Fix the check for toolbx by resolving relative paths before calling `g_lstat()` on them. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--glib/gtimezone.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 1e07cf6f0..00492995c 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -544,6 +544,13 @@ zone_identifier_unix (void)
if (resolved_identifier != NULL)
{
+ if (!g_path_is_absolute (resolved_identifier))
+ {
+ gchar *absolute_resolved_identifier = g_build_filename ("/etc", resolved_identifier, NULL);
+ g_free (resolved_identifier);
+ resolved_identifier = g_steal_pointer (&absolute_resolved_identifier);
+ }
+
if (g_lstat (resolved_identifier, &file_status) == 0)
{
if ((file_status.st_mode & S_IFMT) != S_IFREG)