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
diff --git a/debian/changelog b/debian/changelog
index ec86551..a8264dd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,13 @@ systemd (248.3-1ubuntu8) UNRELEASED; urgency=medium
11 - debian/patches/lp1942113.patch11 - debian/patches/lp1942113.patch
12 - debian/patches/Merge-pull-request-20705-from-yuwata-test-oomd-util.patch12 - debian/patches/Merge-pull-request-20705-from-yuwata-test-oomd-util.patch
1313
14 [ Ratchanan Srirattanamet ]
15 * d/p/debian/timedatectl-lp1650688.patch,
16 d/p/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch:
17 Fix timedated unable to retrieve & properly set timezone on
18 read-only /etc (e.g. Ubuntu Core and system-image-based systems)
19 (LP: #1650688, LP: #1733881)
20
14 -- Lukas Märdian <slyon@ubuntu.com> Mon, 13 Sep 2021 12:59:26 +020021 -- Lukas Märdian <slyon@ubuntu.com> Mon, 13 Sep 2021 12:59:26 +0200
1522
16systemd (248.3-1ubuntu7) impish; urgency=medium23systemd (248.3-1ubuntu7) impish; urgency=medium
diff --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
17new file mode 10064424new file mode 100644
index 0000000..dccf2e0
--- /dev/null
+++ b/debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
@@ -0,0 +1,28 @@
1Description: Fix timezone setting on read-only etc
2 Due to our read-only /etc workaround, the localtime link on such
3 system ends up in /etc/writable, not /etc. To make the link target
4 correct in both normal and such systems, makes the path absolute.
5 .
6 On Ubuntu Core, this eliminates the need for the wrapper script, and
7 makes the DBus interface work properly.
8Author: Ratchanan Srirattanamet <ratchanan@ubports.com>
9Origin: other
10Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
11Forwarded: not-needed (part of read-only /etc workaround)
12Last-Update: 2021-09-24
13---
14This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
15--- a/src/timedate/timedated.c
16+++ b/src/timedate/timedated.c
17@@ -320,9 +320,9 @@
18 return r;
19 }
20
21- source = "../usr/share/zoneinfo/UTC";
22+ source = "/usr/share/zoneinfo/UTC";
23 } else {
24- p = path_join("../usr/share/zoneinfo", c->zone);
25+ p = path_join("/usr/share/zoneinfo", c->zone);
26 if (!p)
27 return -ENOMEM;
28
diff --git a/debian/patches/debian/timedatectl-lp1650688.patch b/debian/patches/debian/timedatectl-lp1650688.patch
0new file mode 10064429new file mode 100644
index 0000000..35bc48c
--- /dev/null
+++ b/debian/patches/debian/timedatectl-lp1650688.patch
@@ -0,0 +1,53 @@
1Description: Fix retrieving timezone on read-only /etc
2 get_timezone() retrieve it by reading the link destination of
3 /etc/localtime, which on systems with read-only /etc will always point
4 to /etc/writable. Makes this function aware of the /etc/writable
5 redirection and handle it.
6 .
7 [ratchanan@ubports.com: add descrtiption and other metadata.]
8Author: Michael Vogt <michael.vogt@ubuntu.com>
9Origin: vendor, https://bugs.launchpad.net/snappy/+bug/1650688/comments/46
10Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1650688
11Forwarded: not-needed (part of read-only /etc workaround)
12Last-Update: 2021-09-24
13---
14This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
15diff --git a/src/basic/time-util.c b/src/basic/time-util.c
16index d7028ac..b9bb4da 100644
17--- a/src/basic/time-util.c
18+++ b/src/basic/time-util.c
19@@ -1391,6 +1391,25 @@ bool clock_supported(clockid_t clock) {
20 }
21 }
22
23+/* Hack for Ubuntu phone: check if path is an existing symlink to
24+ * /etc/writable; if it is, update that instead */
25+static const char* writable_filename(const char *path) {
26+ ssize_t r;
27+ static char realfile_buf[PATH_MAX];
28+ _cleanup_free_ char *realfile = NULL;
29+ const char *result = path;
30+ int orig_errno = errno;
31+
32+ r = readlink_and_make_absolute(path, &realfile);
33+ if (r >= 0 && startswith(realfile, "/etc/writable")) {
34+ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
35+ result = realfile_buf;
36+ }
37+
38+ errno = orig_errno;
39+ return result;
40+}
41+
42 int get_timezone(char **ret) {
43 _cleanup_free_ char *t = NULL;
44 const char *e;
45@@ -1398,7 +1417,7 @@ int get_timezone(char **ret) {
46 int r;
47 bool use_utc_fallback = false;
48
49- r = readlink_malloc("/etc/localtime", &t);
50+ r = readlink_malloc(writable_filename("/etc/localtime"), &t);
51 if (r < 0) {
52 if (r == -ENOENT)
53 use_utc_fallback = true;
diff --git a/debian/patches/series b/debian/patches/series
index 9619486..844b76f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -34,6 +34,8 @@ debian/UBUNTU-journald.service-set-Nice-1-to-dodge-watchdog-on-soft-loc.patch
34debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch34debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch
35debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch35debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch
36debian/UBUNTU-Support-system-image-read-only-etc.patch36debian/UBUNTU-Support-system-image-read-only-etc.patch
37debian/timedatectl-lp1650688.patch
38debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
37debian/UBUNTU-units-disable-journald-watchdog.patch39debian/UBUNTU-units-disable-journald-watchdog.patch
38debian/UBUNTU-Revert-namespace-be-more-careful-when-handling-namespacin.patch40debian/UBUNTU-Revert-namespace-be-more-careful-when-handling-namespacin.patch
39debian/UBUNTU-Revert-cgroup-Continue-unit-reset-if-cgroup-is-busy.patch41debian/UBUNTU-Revert-cgroup-Continue-unit-reset-if-cgroup-is-busy.patch

Subscribers

People subscribed via source and target branches