Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/etc/timezone does not match host system #2190

Closed
danvratil opened this issue Oct 5, 2018 · 13 comments
Closed

/etc/timezone does not match host system #2190

danvratil opened this issue Oct 5, 2018 · 13 comments
Labels
sandbox issue related to sandbox setup

Comments

@danvratil
Copy link
Contributor

Linux distribution and version

KDE neon Developer Edition 18.04 (Ubuntu Bionic)

Flatpak version

Flatpak 1.0.1

Description of the problem

/etc/timezone inside the flatpak is always set to "Universal", so if the host system is configured to any other timezone, applications that depend on the timezone information will show wrong time.

As suggested in flathub/org.kde.kontact#9, host /etc/timezone should be probably exposed to /run/host/monitor.

Steps to reproduce

Change your system timezone to anything other than UTC, run Kontact, observe wrong time (see
flathub/org.kde.kontact#9 for details)

@alexlarsson
Copy link
Member

What is /etc/timezone. I've never heard about that before, and I don't have it on my fedora system. Is it a debian thing? Is there some kind of standard defining how this works?

@danvratil
Copy link
Contributor Author

Debian, but also apparently Arch (and possibly other distros) use it as well. It contains the name of the timezone in Olson format (e.g. "Europe/Prague")

The problem is that Qt looks first for /etc/timezone and falls back to /etc/localtime, so even if /etc/localtime is correct inside of the Flatpak, Qt applications will honor the (wrong) /etc/timezone.

I could find only this: https://wiki.debian.org/TimeZoneChanges

@Erick555
Copy link
Contributor

Erick555 commented Oct 5, 2018

There is no /etc/timezone in Arch Linux. I don't see any package providing it in Debian or Ubuntu either. The content from that wiki page is about ten years old. Isn't this some ancient waste? Perhaps # rm /etc/timezone will fix your issue.

@alexlarsson
Copy link
Member

Another alternative is to remove /etc/timezone from the runtime. It seems to be in the 1.6 freedesktop runtime, but not in the new (18.08) version. If that is not there, what does Qt use for timezone then?

@Erick555
Copy link
Contributor

Erick555 commented Oct 6, 2018

@alexlarsson It was already said that it falls back to /etc/localtime which fixes the problem.

@danvratil
Copy link
Contributor Author

I'm pretty sure it's not ancient: I had it on my Ubuntu 16.04 based system that I installed about 5 months ago - maybe it's created by some tool on boot?

In any case, the KDE Runtime is based on freedesktop 1.6 at the moment, so the file is there - since this only seems to affect Qt apps, maybe we can remove it when building the KDE runtime for now.

@alexlarsson
Copy link
Member

Its better to have all runtimes behave in the same way wrt something as core as timezone config i think

@alexlarsson
Copy link
Member

It seems to me that Qt already prefers the /etc/localtime symlink value:
http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qtimezoneprivate_tz.cpp
http://code.qt.io/cgit/qt/qtbase.git/commit/?id=110e49c9cecca34dfacad33d19e04612cc2671b2

However, I looked at both the Qt code and the glib code (https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gtimezone.c#L406) and it seems that both rely on the symlink having a special format, which it doesn't at the moment.

So, for the qt code it would work if we made the symlink be to like /run/host/monitor/zoneinfo/Europe/Stockholm, but the glib implementation relies on the resolved path being in /usr/share/zoneinfo (or at least in getenv(TZDIR)), so that would not work there.

And, once we have to have a special value for the symlink in /etc then the monitor is starting to become less useful. Yes, the host might have more up-to-date timezone data than the runtime, but we can't update the symlink value at runtime when the user changes timezone...

I wonder if we should instead just bind-mount the host zoneinfo over /usr/share/zoneinfo and just accept that you have to restart the app if you change timezone.

Any other ideas?

@alexlarsson
Copy link
Member

Alternatively, we could implement /etc/timezone in the monitor, and then patch the glib in the runtime to support that. Then we could support the timezone changing at runtime.

Actually, glib already reads /var/db/zoneinfo with similar sematics to /etc/filesystem, so we could make both be symlinks...

@Erick555
Copy link
Contributor

Erick555 commented Oct 8, 2018

As /etc/timezone is redundant to /etc/localtime and doesn't exist in some systems (Fedora, Arch - we can assume no application depends on it for this reason) then getting rid of it seems the easiest way. 18.08 doesn't have it so when KDE runtime will upgrade the problem will be gone.

alexlarsson added a commit to alexlarsson/flatpak that referenced this issue Oct 8, 2018
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes flatpak#2190
@alexlarsson
Copy link
Member

@Erick555 it is redundant on the host, but we can't really implement it in the sandbox because it relies on pointing into /usr, which is in the runtime that flatpak has no guarantees about (i.e. it might not have the same timezone data as the host). Also, it has to be a direct symlink, which means we can only specify it at sandbox creation and never update it. That makes it not ideal for flatpak.

@alexlarsson
Copy link
Member

@danvratil Whats your opinion on the approach in #2214

@danvratil
Copy link
Contributor Author

@alexlarsson Looks good. I tested it with the Kontact flatpak and the timezone was set correctly, so it definitely fixes the timezone issue for Qt/KDE apps. Thanks for fixing this so quickly.

@matthiasclasen matthiasclasen added the sandbox issue related to sandbox setup label Oct 10, 2018
alexlarsson added a commit to alexlarsson/flatpak that referenced this issue Oct 10, 2018
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes flatpak#2190
alexlarsson added a commit to alexlarsson/flatpak that referenced this issue Oct 11, 2018
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes flatpak#2190

Closes: flatpak#2214
Approved by: alexlarsson

(cherry picked from commit 0b6844f)
rh-atomic-bot pushed a commit that referenced this issue Oct 11, 2018
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes #2190

Closes: #2214
Approved by: alexlarsson

(cherry picked from commit 0b6844f)

Closes: #2237
Approved by: alexlarsson
alexlarsson added a commit that referenced this issue Oct 12, 2018
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes #2190

Closes: #2214
Approved by: alexlarsson

(cherry picked from commit 0b6844f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sandbox issue related to sandbox setup
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants