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

Proposed by Ratchanan Srirattanamet
Status: Needs review
Proposed branch: ~peat-new/ubuntu/+source/systemd:ubuntu-impish_-_timedated-symlink
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-impish
Diff against target: 124 lines (+90/-0)
4 files modified
debian/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)
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Pending
Review via email: mp+409312@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.

Unmerged commits

bc88e0f... by Ratchanan Srirattanamet

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

LP: #1650688
LP: #1733881

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 ec86551..a8264dd 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -11,6 +11,13 @@ systemd (248.3-1ubuntu8) UNRELEASED; urgency=medium
6 - debian/patches/lp1942113.patch
7 - debian/patches/Merge-pull-request-20705-from-yuwata-test-oomd-util.patch
8
9+ [ Ratchanan Srirattanamet ]
10+ * d/p/debian/timedatectl-lp1650688.patch,
11+ d/p/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch:
12+ Fix timedated unable to retrieve & properly set timezone on
13+ read-only /etc (e.g. Ubuntu Core and system-image-based systems)
14+ (LP: #1650688, LP: #1733881)
15+
16 -- Lukas Märdian <slyon@ubuntu.com> Mon, 13 Sep 2021 12:59:26 +0200
17
18 systemd (248.3-1ubuntu7) impish; urgency=medium
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 9619486..844b76f 100644
114--- a/debian/patches/series
115+++ b/debian/patches/series
116@@ -34,6 +34,8 @@ debian/UBUNTU-journald.service-set-Nice-1-to-dodge-watchdog-on-soft-loc.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-Revert-namespace-be-more-careful-when-handling-namespacin.patch
124 debian/UBUNTU-Revert-cgroup-Continue-unit-reset-if-cgroup-is-busy.patch

Subscribers

People subscribed via source and target branches