Merge ~peat-new/ubuntu/+source/systemd:ubuntu-focal_-_timedated-symlink into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-focal

Proposed by Ratchanan Srirattanamet
Status: Merged
Merged at revision: 9cbfa9126a0a7980e55889d9b44c1b4b210520cf
Proposed branch: ~peat-new/ubuntu/+source/systemd:ubuntu-focal_-_timedated-symlink
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-focal
Diff against target: 124 lines (+93/-0)
4 files modified
debian/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)
Reviewer Review Type Date Requested Status
Snappy Developers Pending
Canonical Foundations Team Pending
Dimitri John Ledkov Pending
Review via email: mp+409313@code.launchpad.net

Commit message

Fix timedated unable to retrieve & properly set timezone on read-only /etc

LP: #1650688
LP: #1733881

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote :

Didn't we already merge this? Or did we do it for bionic only?

https://bugs.launchpad.net/snappy/+bug/1650688/comments/66

Revision history for this message
Ratchanan Srirattanamet (peat-new) wrote :

It's also in for Focal, just that it's cherry-pick in to resolve changelog.

https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?h=ubuntu-focal&id=9cbfa9126a0a7980e55889d9b44c1b4b210520cf

https://bugs.launchpad.net/snappy/+bug/1650688/comments/64

As such, I'll close this MP and the related ones.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 98be76e..690e6e6 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+systemd (245.4-4ubuntu3.14) UNRELEASED; urgency=medium
7+
8+ * d/p/debian/timedatectl-lp1650688.patch,
9+ d/p/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch:
10+ Fix timedated unable to retrieve & properly set timezone on
11+ read-only /etc (e.g. Ubuntu Core and system-image-based systems)
12+ (LP: #1650688, LP: #1733881)
13+
14+ -- Ratchanan Srirattanamet <ratchanan@ubports.com> Fri, 24 Sep 2021 16:54:31 +0700
15+
16 systemd (245.4-4ubuntu3.13) focal; urgency=medium
17
18 * d/p/dell-clamshell-accel-location-base-with-sku.patch:
19diff --git a/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch b/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
20new file mode 100644
21index 0000000..dccf2e0
22--- /dev/null
23+++ b/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
24@@ -0,0 +1,28 @@
25+Description: Fix timezone setting on read-only etc
26+ Due to our read-only /etc workaround, the localtime link on such
27+ system ends up in /etc/writable, not /etc. To make the link target
28+ correct in both normal and such systems, makes the path absolute.
29+ .
30+ On Ubuntu Core, this eliminates the need for the wrapper script, and
31+ makes the DBus interface work properly.
32+Author: Ratchanan Srirattanamet <ratchanan@ubports.com>
33+Origin: other
34+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
35+Forwarded: not-needed (part of read-only /etc workaround)
36+Last-Update: 2021-09-24
37+---
38+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
39+--- a/src/timedate/timedated.c
40++++ b/src/timedate/timedated.c
41+@@ -320,9 +320,9 @@
42+ return r;
43+ }
44+
45+- source = "../usr/share/zoneinfo/UTC";
46++ source = "/usr/share/zoneinfo/UTC";
47+ } else {
48+- p = path_join("../usr/share/zoneinfo", c->zone);
49++ p = path_join("/usr/share/zoneinfo", c->zone);
50+ if (!p)
51+ return -ENOMEM;
52+
53diff --git a/debian/patches/debian/timedatectl-lp1650688.patch b/debian/patches/debian/timedatectl-lp1650688.patch
54new file mode 100644
55index 0000000..35bc48c
56--- /dev/null
57+++ b/debian/patches/debian/timedatectl-lp1650688.patch
58@@ -0,0 +1,53 @@
59+Description: Fix retrieving timezone on read-only /etc
60+ get_timezone() retrieve it by reading the link destination of
61+ /etc/localtime, which on systems with read-only /etc will always point
62+ to /etc/writable. Makes this function aware of the /etc/writable
63+ redirection and handle it.
64+ .
65+ [ratchanan@ubports.com: add descrtiption and other metadata.]
66+Author: Michael Vogt <michael.vogt@ubuntu.com>
67+Origin: vendor, https://bugs.launchpad.net/snappy/+bug/1650688/comments/46
68+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
69+Forwarded: not-needed (part of read-only /etc workaround)
70+Last-Update: 2021-09-24
71+---
72+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
73+diff --git a/src/basic/time-util.c b/src/basic/time-util.c
74+index d7028ac..b9bb4da 100644
75+--- a/src/basic/time-util.c
76++++ b/src/basic/time-util.c
77+@@ -1391,6 +1391,25 @@ bool clock_supported(clockid_t clock) {
78+ }
79+ }
80+
81++/* Hack for Ubuntu phone: check if path is an existing symlink to
82++ * /etc/writable; if it is, update that instead */
83++static const char* writable_filename(const char *path) {
84++ ssize_t r;
85++ static char realfile_buf[PATH_MAX];
86++ _cleanup_free_ char *realfile = NULL;
87++ const char *result = path;
88++ int orig_errno = errno;
89++
90++ r = readlink_and_make_absolute(path, &realfile);
91++ if (r >= 0 && startswith(realfile, "/etc/writable")) {
92++ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
93++ result = realfile_buf;
94++ }
95++
96++ errno = orig_errno;
97++ return result;
98++}
99++
100+ int get_timezone(char **ret) {
101+ _cleanup_free_ char *t = NULL;
102+ const char *e;
103+@@ -1398,7 +1417,7 @@ int get_timezone(char **ret) {
104+ int r;
105+ bool use_utc_fallback = false;
106+
107+- r = readlink_malloc("/etc/localtime", &t);
108++ r = readlink_malloc(writable_filename("/etc/localtime"), &t);
109+ if (r < 0) {
110+ if (r == -ENOENT)
111+ use_utc_fallback = true;
112diff --git a/debian/patches/series b/debian/patches/series
113index 9da13cd..d529d4d 100644
114--- a/debian/patches/series
115+++ b/debian/patches/series
116@@ -44,6 +44,8 @@ debian/UBUNTU-networkd-if-RA-was-implicit-do-not-await-ndisc_con.patch
117 debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch
118 debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch
119 debian/UBUNTU-Support-system-image-read-only-etc.patch
120+debian/timedatectl-lp1650688.patch
121+debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
122 debian/UBUNTU-units-disable-journald-watchdog.patch
123 debian/UBUNTU-core-set-run-size-to-10-like-initramfs-tools-does.patch
124 Revert-namespace-be-more-careful-when-handling-namespacin.patch

Subscribers

People subscribed via source and target branches