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

Proposed by Ratchanan Srirattanamet
Status: Merged
Merged at revision: b58c1227b47eb2b8e800d8667791a6dea4558ffc
Proposed branch: ~peat-new/ubuntu/+source/systemd:ubuntu-jammy_-_timedated-symlink
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-jammy
Diff against target: 131 lines (+91/-0)
4 files modified
debian/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)
Reviewer Review Type Date Requested Status
Dan Streetman meaningless Disapprove
Dimitri John Ledkov Pending
Review via email: mp+411825@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
Dan Streetman (ddstreet) wrote :

"Hack for Ubuntu phone"...personally I'm pretty strongly *against* these hacks to systemd. I'd prefer to rip all the hackery out completely from Ubuntu's systemd; Ubuntu core should figure out some way for things to work without having to patch everything.

I'm adding my personal rejection to this, but it certainly isn't up to me.

review: Disapprove (meaningless)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Dan! I'm still in the process of investigating this through, but at a first sight Ratchanan's patch appears correct and needed: we already have a similar patch in debian/patches/debian/UBUNTU-Support-system-image-read-only-etc.patch but for some reason (systemd code changed, or some wrong patch refresh?) it is not complete.

The bug, indeed, still exists (I just tested on Ubuntu Core18 in QEMU), and tomorrow I'll try this branch and report back. Most likely we want the first patch to be merged with the existing one which I mentioned before, however.

Revision history for this message
Dan Streetman (ddstreet) wrote :

> we already have a similar patch in debian/patches/debian/UBUNTU-Support-system-image-read-only-etc.patch

from 2014. Which IMHO should be dropped. We should not carry hacks for 7 years; something should be changed *correctly*. In this case, it seems like that something is either upstream systemd (unlikely), or ubuntu core needs to figure out how to work without hacking systemd.

> but for some reason (systemd code changed, or some wrong patch refresh?) it is
> not complete.

One of many reasons why this kind of forever-hacking junk is horrible.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Dan, let's continue the discussion in https://bugs.launchpad.net/snappy/+bug/1650688 :-)

Revision history for this message
Michael Vogt (mvo) wrote :

Fwiw, I asked Valentin from my team to look into a better solution that can be upstreamed. However in the short term we have real customers with real issue because this is missing. I understand the concerns and I also feel uneasy about this (I have ported this or similar patches more than once and did not like it one bit). I would suggest we merge this one to unblock our customer and in parallel work on a proper solution. How does that sound?

Revision history for this message
Dan Streetman (ddstreet) wrote :

> However in the short term we have real customers with real issue because this is missing

er, this MR is for jammy. If there are any existing real customers using jammy, that's a problem. ;-)

Fixing this in stable releases is a completely separate issue from hacking the devel release.

As I said, this isn't up to me; I have no formal ownership of systemd for Ubuntu and I don't really do anything for systemd for the devel release. However, IMHO this absolutely shouldn't go into Jammy; some kind of *correct* design of core22 should be done to allow 'stock' systemd to work without hacks. But again, feel free to disregard my opinion and throw it in :)

As far as fixing the stable releases, I'm certainly not thrilled about the approach, but it seems fine to get the hack(s) working correctly if there is a problem with it on core18 or core20 (or core16); I don't see any reason to redesign anything on stable releases.

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

> er, this MR is for jammy.

I submitted this for Jammy because, in my understanding, SRU requires that the change be included in the current devel series first.

I've already submitted the MPs for Focal and Bionic as well [1][2]. For us at UBports, the Focal series is the most important, because we're targetting Focal for our big upgrade. So, if it's fixed in Focal, it's Ok for me if this specific MP won't be merged. I'm not sure how Ubuntu's development process works though.

[1] https://code.launchpad.net/~peat-new/ubuntu/+source/systemd/+git/systemd/+merge/409313
[2] https://code.launchpad.net/~peat-new/ubuntu/+source/systemd/+git/systemd/+merge/409314

Revision history for this message
Dan Streetman (ddstreet) wrote :

> I submitted this for Jammy because, in my understanding, SRU requires that the change be included in the current devel series first.

right, that's the normal requirement; however the fix used in stable releases doesn't necessarily have to be the same as a fix in the devel relase and/or upstream; the SRU fix can/should be different if the upstream fix is larger or more complex than is needed to fix something in a stable release. For example, if a bug was fixed upstream by a large refactoring/rewrite of some subsystem, it wouldn't be appropriate to backport the rewrite, and would be fine to manually create some patch to fix only a specific problem, even though that patch would not be how the bug was fixed in later releases.

For this particular issue, and again IMHO, this should be fixed *correctly* upstream (i.e. the devel release), and fixed *simply* (i.e. with the patch to hack systemd) in stable releases (though SRUing a "correct" fix would be preferable, if possible).

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 39a517f..0e79a4f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,5 +1,6 @@
6 systemd (248.3-1ubuntu9) UNRELEASED; urgency=medium
7
8+ [ Dan Streetman ]
9 * d/p/lp1950508-cgroup-check-if-any-controller-is-in-use-as-v1.patch:
10 Use cgroupv1 in container if host using cgroupv1
11 (LP: #1950508)
12@@ -7,6 +8,13 @@ systemd (248.3-1ubuntu9) UNRELEASED; urgency=medium
13 New meson doesn't allow bool + bool
14 (LP: #1950511)
15
16+ [ Ratchanan Srirattanamet ]
17+ * d/p/debian/timedatectl-lp1650688.patch,
18+ d/p/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch:
19+ Fix timedated unable to retrieve & properly set timezone on
20+ read-only /etc (e.g. Ubuntu Core and system-image-based systems)
21+ (LP: #1650688, LP: #1733881)
22+
23 -- Dan Streetman <ddstreet@ieee.org> Wed, 10 Nov 2021 13:47:28 -0500
24
25 systemd (248.3-1ubuntu8) impish; urgency=medium
26diff --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
27new file mode 100644
28index 0000000..dccf2e0
29--- /dev/null
30+++ b/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
31@@ -0,0 +1,28 @@
32+Description: Fix timezone setting on read-only etc
33+ Due to our read-only /etc workaround, the localtime link on such
34+ system ends up in /etc/writable, not /etc. To make the link target
35+ correct in both normal and such systems, makes the path absolute.
36+ .
37+ On Ubuntu Core, this eliminates the need for the wrapper script, and
38+ makes the DBus interface work properly.
39+Author: Ratchanan Srirattanamet <ratchanan@ubports.com>
40+Origin: other
41+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
42+Forwarded: not-needed (part of read-only /etc workaround)
43+Last-Update: 2021-09-24
44+---
45+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
46+--- a/src/timedate/timedated.c
47++++ b/src/timedate/timedated.c
48+@@ -320,9 +320,9 @@
49+ return r;
50+ }
51+
52+- source = "../usr/share/zoneinfo/UTC";
53++ source = "/usr/share/zoneinfo/UTC";
54+ } else {
55+- p = path_join("../usr/share/zoneinfo", c->zone);
56++ p = path_join("/usr/share/zoneinfo", c->zone);
57+ if (!p)
58+ return -ENOMEM;
59+
60diff --git a/debian/patches/debian/timedatectl-lp1650688.patch b/debian/patches/debian/timedatectl-lp1650688.patch
61new file mode 100644
62index 0000000..35bc48c
63--- /dev/null
64+++ b/debian/patches/debian/timedatectl-lp1650688.patch
65@@ -0,0 +1,53 @@
66+Description: Fix retrieving timezone on read-only /etc
67+ get_timezone() retrieve it by reading the link destination of
68+ /etc/localtime, which on systems with read-only /etc will always point
69+ to /etc/writable. Makes this function aware of the /etc/writable
70+ redirection and handle it.
71+ .
72+ [ratchanan@ubports.com: add descrtiption and other metadata.]
73+Author: Michael Vogt <michael.vogt@ubuntu.com>
74+Origin: vendor, https://bugs.launchpad.net/snappy/+bug/1650688/comments/46
75+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
76+Forwarded: not-needed (part of read-only /etc workaround)
77+Last-Update: 2021-09-24
78+---
79+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
80+diff --git a/src/basic/time-util.c b/src/basic/time-util.c
81+index d7028ac..b9bb4da 100644
82+--- a/src/basic/time-util.c
83++++ b/src/basic/time-util.c
84+@@ -1391,6 +1391,25 @@ bool clock_supported(clockid_t clock) {
85+ }
86+ }
87+
88++/* Hack for Ubuntu phone: check if path is an existing symlink to
89++ * /etc/writable; if it is, update that instead */
90++static const char* writable_filename(const char *path) {
91++ ssize_t r;
92++ static char realfile_buf[PATH_MAX];
93++ _cleanup_free_ char *realfile = NULL;
94++ const char *result = path;
95++ int orig_errno = errno;
96++
97++ r = readlink_and_make_absolute(path, &realfile);
98++ if (r >= 0 && startswith(realfile, "/etc/writable")) {
99++ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
100++ result = realfile_buf;
101++ }
102++
103++ errno = orig_errno;
104++ return result;
105++}
106++
107+ int get_timezone(char **ret) {
108+ _cleanup_free_ char *t = NULL;
109+ const char *e;
110+@@ -1398,7 +1417,7 @@ int get_timezone(char **ret) {
111+ int r;
112+ bool use_utc_fallback = false;
113+
114+- r = readlink_malloc("/etc/localtime", &t);
115++ r = readlink_malloc(writable_filename("/etc/localtime"), &t);
116+ if (r < 0) {
117+ if (r == -ENOENT)
118+ use_utc_fallback = true;
119diff --git a/debian/patches/series b/debian/patches/series
120index 81330b5..0880584 100644
121--- a/debian/patches/series
122+++ b/debian/patches/series
123@@ -34,6 +34,8 @@ debian/UBUNTU-journald.service-set-Nice-1-to-dodge-watchdog-on-soft-loc.patch
124 debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch
125 debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch
126 debian/UBUNTU-Support-system-image-read-only-etc.patch
127+debian/timedatectl-lp1650688.patch
128+debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
129 debian/UBUNTU-units-disable-journald-watchdog.patch
130 debian/UBUNTU-Revert-namespace-be-more-careful-when-handling-namespacin.patch
131 debian/UBUNTU-Revert-cgroup-Continue-unit-reset-if-cgroup-is-busy.patch

Subscribers

People subscribed via source and target branches