timedatectl set-timezone fails on UC16
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Triaged
|
High
|
Unassigned | ||
systemd (Ubuntu) |
Fix Released
|
Medium
|
Lukas Märdian | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Undecided
|
Unassigned | ||
Hirsute |
Won't Fix
|
Undecided
|
Unassigned | ||
Impish |
Won't Fix
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Medium
|
Lukas Märdian |
Bug Description
SRU
===
[Impact]
* The bug prevents timedated from recognizing and correctly set the system's timezone when running Ubuntu Core 16, 18 and 20.
* This causes by timedated fails to take Ubuntu Core's /etc/writable redirection into account.
* The recognizing part is fixed by making the code take writable redirection into account.
* The set part is fixed by making the code link to the absolute path instead of a relative one.
* Currently core snaps worked around the set part by providing a wrapper script which re-create /etc/writable/
[Test Plan]
* On classics systems: ensure the proposed systemd package is installed.
On Ubuntu Core systems: build a new core snap including proposed package, and install it. Replaces timedatectl with timedatectl.real to test skipping the wrapper.
(Note that one can simulate core snap's /etc/writable redirection by running this image creation hook [1] on the system.)
* On freshly boot system: query the timezone using `timedatectl`. The timezone should corresponds to `readlink -f /etc/localtime` and does not show `n/a`.
* Set a new timezone: `sudo timedatectl set-timezone Asia/Bangkok`. `readlink -f /etc/localtime` should points to an existing file.
* Run `sudo systemctl restart systemd-
* Run `sudo systemctl status systemd-
[Where problems could occur]
* It's possible that the redirection handling code will be sub-par and causes crash. However, it's not likely because the similar pieces of code is in the previous patch since Ubuntu 16.04.
* If it does: the patched `get_timezone()` function is used in 2 places: the networkd's DHCP server [3] and the timedated itself.
- Networkd is used primarily on servers where NetworkManage is absent. It's possible that this patch causes the user to loss access to the server due to networkd crash when setting up network interfaces, and requires physical access to fix. However, the code path is executed when DHCP is enabled only. I think it's not common for users to have networkd's DHCP server enabled: the feature seems to gear towards desktop users wanting to share internet connection, and in those cases they're more likely to use NetworkManager.
- The timedated itself is likely used by the programs that involves in time-related functions. If a crash occur, in the worst case users won't be able to set time or timezone via timedated. However, users should still be able to e.g. set time using `date` or set timezone using /etc/localtime (assuming online guides still consider systems without systemd). Timedated is DBus-activated, and thus a crash should be self-healing.
* The set part would also affects the clasic systems. However, I believe nothing else actually rely on /etc/localtime being a relative path, otherwise the /etc/writable redirection would causes even more problem, and would have been reported.
[3] Yes, I'm surprised that there's a DHCP server inside systemd codebase.
[Other Info]
* This is also useful for UBports's Ubuntu Touch. We continue using system-image system where the rootfs is read-only, and thus is affected by this bug similarly to Ubuntu Core. I've tested the Focal version of the package on our (currently in development) Focal Ubuntu Touch image, and the fix works.
------------
[Original bug description]
On a system running UC16, the file /etc/localtime is a link that points to /etc/writable/
On a freshly installed system, /etc/writable/
If timedatectl is used to set the timezone to something else, timedated updates the localtime symbolic link with a relative path to the zoneinfo directory, which results in an invalid link.
$ sudo timedatectl set-timezone America/Detroit
$ sudo timedatectl
Local time: Fri 2016-12-16 18:18:49 EST
Universal time: Fri 2016-12-16 23:18:49 UTC
RTC time: Fri 2016-12-16 23:18:49
Time zone: America/Detroit (EST, -0500)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
$ ls -l /etc/writable/
/etc/writable/
admin@localhost
Fri Dec 16 23:20:07 UTC 2016
I'm running the latest core snap from the candidate channel which contains snapd 2.18.1. Hardware details and/or more debug information can be supplied on request.
See 'man 3 timezone' and 'man timedatectl' for more details.
Related branches
- Dan Streetman: Disapprove (meaningless)
- Dimitri John Ledkov: Pending requested
-
Diff: 131 lines (+91/-0)4 files modifieddebian/changelog (+8/-0)
debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch (+28/-0)
debian/patches/debian/timedatectl-lp1650688.patch (+53/-0)
debian/patches/series (+2/-0)
- Dimitri John Ledkov: Pending requested
-
Diff: 119 lines (+88/-0)4 files modifieddebian/changelog (+10/-0)
debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch (+25/-0)
debian/patches/debian/timedatectl-lp1650688.patch (+51/-0)
debian/patches/series (+2/-0)
- Snappy Developers: Pending requested
- Canonical Foundations Team: Pending requested
- Dimitri John Ledkov: Pending requested
-
Diff: 124 lines (+93/-0)4 files modifieddebian/changelog (+10/-0)
debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch (+28/-0)
debian/patches/debian/timedatectl-lp1650688.patch (+53/-0)
debian/patches/series (+2/-0)
- Dimitri John Ledkov: Pending requested
-
Diff: 124 lines (+90/-0)4 files modifieddebian/changelog (+7/-0)
debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch (+28/-0)
debian/patches/debian/timedatectl-lp1650688.patch (+53/-0)
debian/patches/series (+2/-0)
Changed in snappy: | |
status: | New → Confirmed |
Changed in snappy: | |
status: | Fix Released → Confirmed |
tags: | added: hwe |
Changed in snappy: | |
status: | Confirmed → In Progress |
Changed in snappy: | |
status: | New → Triaged |
Changed in snappy: | |
assignee: | Oliver Grawert (ogra) → nobody |
Changed in systemd (Ubuntu): | |
importance: | Undecided → Medium |
tags: | added: rls-jj-incoming |
tags: | added: fr-1885 |
tags: | removed: rls-jj-incoming |
Changed in systemd (Ubuntu Jammy): | |
assignee: | nobody → Lukas Märdian (slyon) |
Changed in systemd (Ubuntu Jammy): | |
status: | Confirmed → In Progress |
status: | In Progress → Fix Committed |
affects: | snappy → snapd |
I can reproduce this on core revision 1083 (armhf).
@ogra any idea how we can easily fix this? Whoever updates the symlink at /etc/localtime needs to respect that /etc/localtime is also now just a symlink to /etc/writable/ localtime and that the proper target for the symlink needs to be ../../usr/ share/zoneinfo/ America/ Detroit.
All this causes timedated to end up in UTC state.
test@localhost: /etc$ sudo timedatectl
Local time: Thu 2017-02-09 06:21:21 UTC
Universal time: Thu 2017-02-09 06:21:21 UTC
RTC time: n/a
Time zone: n/a (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no