Skip to content

Commit

Permalink
Do not accept timezone name if it's not in region/city format
Browse files Browse the repository at this point in the history
The code in plugins/datetime/system-timezone.c does its best to determine timezone name.
Upstream python code in `cinnamon-setting calendar` expects timezone name in `Region/City` format.
So recursive_compare() handles cases when /etc/localtime and files in /usr/share/zoneinfo are symlinks, hardlinks, copies, etc to provide the proper name.

This patch fixes case when all timezone files are copies.
Instead of returning the first timzeon file (name) found in SYSTEM_ZONEINFODIR (/usr/share/zoneinfo) it keeps looking for a name with a slash "/" in the name.

Example:
A user lives in US Colorado near Denver. The timezone name `cinnamon-setting calendar` would expect is America/Denver.
If the user is using OS where all the timezone files are copies (not any kind of links) `cinnamon-setting calendar` would fail.
That happens because the `plugins/datetime/system-timezone.c` code would be searching SYSTEM_ZONEINFODIR folder and would find `/usr/share/zoneinfo/Navajo` file first.
So `cinnamon-setting calendar` would get `Navajo` instead of `Americs/Denver` as timezone name.
Fix this issue by checking for a slash in the timezone name and keep looking if it's not the case.
  • Loading branch information
timp87 committed Oct 10, 2024
1 parent d97f923 commit ac05125
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/datetime/system-timezone.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,19 @@ recursive_compare (struct stat *localtime_stat,
CompareFiles compare_func)
{
struct stat file_stat;
char *relpath = NULL;

if (g_stat (file, &file_stat) != 0)
return NULL;

if (S_ISREG (file_stat.st_mode)) {
relpath = system_timezone_strip_path_if_valid (file);
if (g_strstr_len (relpath, -1, "/") == NULL) {
g_free (relpath);
return NULL;
}
g_free (relpath);

if (compare_func (localtime_stat,
&file_stat,
localtime_content,
Expand Down

0 comments on commit ac05125

Please sign in to comment.