Comment 5 for bug 140934

Revision history for this message
Colin Watson (cjwatson) wrote :

This is a system-tools-backends bug. Observe the following code in /usr/share/system-tools-backends-2.0/scripts/Time/TimeDate.pm:

  *TZLIST = &Utils::File::open_read_from_names($zoneinfo_dir . "/zone.tab");
  if (not *TZLIST) { return; }

  &Utils::Report::do_report ("time_timezone_scan");

  # Get the filesize for /etc/localtime so that we don't have to execute
  # a diff for every file, only for file with the correct size. This speeds
  # up loading
  $size_search = (stat ($local_time_file))[7];

  while (<TZLIST>)
  {
    if (/^\#/) { next; } # Skip comments.
    ($d, $d, $zone) = split /[\t ]+/, $_; # Get 3rd column.
    chomp $zone; # Remove linefeeds.

    # See if this zone file matches the installed one.
    &Utils::Report::do_report ("time_timezone_cmp", $zone);
    $size_test = (stat("$zoneinfo_dir/$zone"))[7];
    if ($size_test eq $size_search)
    {
      if (!&Utils::File::run ("diff $zoneinfo_dir/$zone $local_time_file"))
      {
        # Found a match.
        last;
      }
    }

    $zone = "";
  }

  close (TZLIST);
  return $zone;

This means that the first zone listed in /usr/share/zoneinfo/zone.tab whose zone file matches the contents of /etc/localtime (since we don't set up /etc/localtime as a symlink for various other good reasons) will be used. In this case, that happens to be Europe/Sarajevo, because Europe/Sarajevo is a copy of Europe/Belgrade and is the default for Bosnia, which comes before Serbia in zone.tab.

I think the correct fix for this bug is to attempt to open /etc/timezone and check whether the timezone named there matches the contents of /etc/localtime, before doing this exhaustive search. That would be faster as well.