gtimezone: Fix symlink checks on relative link targets

The changes in 6265b2e6f7 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>
This commit is contained in:
Philip Withnall 2022-10-24 12:35:29 +01:00
parent 662661a8d0
commit f8c80391ae

View File

@ -544,6 +544,13 @@ zone_identifier_unix (void)
if (resolved_identifier != NULL) 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 (g_lstat (resolved_identifier, &file_status) == 0)
{ {
if ((file_status.st_mode & S_IFMT) != S_IFREG) if ((file_status.st_mode & S_IFMT) != S_IFREG)