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

Proposed by Ratchanan Srirattanamet
Status: Merged
Merged at revision: 95acefc991059eae388d50cb9eba04f06af59d59
Proposed branch: ~peat-new/ubuntu/+source/systemd:ubuntu-bionic_-_timedated-symlink
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-bionic
Diff against target: 119 lines (+88/-0)
4 files modified
debian/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)
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Pending
Review via email: mp+409314@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.

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 5e2e2aa..eeb41da 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+systemd (237-3ubuntu10.53) 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 (237-3ubuntu10.52) bionic; urgency=medium
17
18 * d/extra/dhclient-enter-resolved-hook:
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..61841f4
22--- /dev/null
23+++ b/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
24@@ -0,0 +1,25 @@
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+@@ -118,7 +118,7 @@
42+ return r;
43+ }
44+
45+- p = strappend("../usr/share/zoneinfo/", c->zone);
46++ p = strappend("/usr/share/zoneinfo/", c->zone);
47+ if (!p)
48+ return log_oom();
49+
50diff --git a/debian/patches/debian/timedatectl-lp1650688.patch b/debian/patches/debian/timedatectl-lp1650688.patch
51new file mode 100644
52index 0000000..f5ab19e
53--- /dev/null
54+++ b/debian/patches/debian/timedatectl-lp1650688.patch
55@@ -0,0 +1,51 @@
56+Description: Fix retrieving timezone on read-only /etc
57+ get_timezone() retrieve it by reading the link destination of
58+ /etc/localtime, which on systems with read-only /etc will always point
59+ to /etc/writable. Makes this function aware of the /etc/writable
60+ redirection and handle it.
61+ .
62+ [ratchanan@ubports.com: add descrtiption and other metadata.]
63+ [ratchanan@ubports.com: backport the patch for bionic]
64+Author: Michael Vogt <michael.vogt@ubuntu.com>
65+Origin: backport, https://bugs.launchpad.net/snappy/+bug/1650688/comments/46
66+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
67+Forwarded: not-needed (part of read-only /etc workaround)
68+Last-Update: 2021-09-24
69+---
70+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
71+--- a/src/basic/time-util.c
72++++ b/src/basic/time-util.c
73+@@ -1380,13 +1380,32 @@
74+ }
75+ }
76+
77++/* Hack for Ubuntu phone: check if path is an existing symlink to
78++ * /etc/writable; if it is, update that instead */
79++static const char* writable_filename(const char *path) {
80++ ssize_t r;
81++ static char realfile_buf[PATH_MAX];
82++ _cleanup_free_ char *realfile = NULL;
83++ const char *result = path;
84++ int orig_errno = errno;
85++
86++ r = readlink_and_make_absolute(path, &realfile);
87++ if (r >= 0 && startswith(realfile, "/etc/writable")) {
88++ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
89++ result = realfile_buf;
90++ }
91++
92++ errno = orig_errno;
93++ return result;
94++}
95++
96+ int get_timezone(char **tz) {
97+ _cleanup_free_ char *t = NULL;
98+ const char *e;
99+ char *z;
100+ int r;
101+
102+- r = readlink_malloc("/etc/localtime", &t);
103++ r = readlink_malloc(writable_filename("/etc/localtime"), &t);
104+ if (r < 0) {
105+ if (r != -EINVAL)
106+ return r; /* returns EINVAL if not a symlink */
107diff --git a/debian/patches/series b/debian/patches/series
108index 093231f..746c816 100644
109--- a/debian/patches/series
110+++ b/debian/patches/series
111@@ -97,6 +97,8 @@ sd-bus-if-we-receive-an-invalid-dbus-message-ignore-.patch
112 journal-do-not-remove-multiple-spaces-after-identifi.patch
113 stop-mount-error-propagation.patch
114 Support-system-image-read-only-etc.patch
115+debian/timedatectl-lp1650688.patch
116+debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
117 fix-race-daemon-reload-11121.patch
118 virt-detect-WSL-environment-as-a-container-id-wsl.patch
119 CVE-2019-3842.patch

Subscribers

People subscribed via source and target branches