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
diff --git a/debian/changelog b/debian/changelog
index 98be76e..690e6e6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
1systemd (245.4-4ubuntu3.14) UNRELEASED; urgency=medium
2
3 * d/p/debian/timedatectl-lp1650688.patch,
4 d/p/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch:
5 Fix timedated unable to retrieve & properly set timezone on
6 read-only /etc (e.g. Ubuntu Core and system-image-based systems)
7 (LP: #1650688, LP: #1733881)
8
9 -- Ratchanan Srirattanamet <ratchanan@ubports.com> Fri, 24 Sep 2021 16:54:31 +0700
10
1systemd (245.4-4ubuntu3.13) focal; urgency=medium11systemd (245.4-4ubuntu3.13) focal; urgency=medium
212
3 * d/p/dell-clamshell-accel-location-base-with-sku.patch:13 * d/p/dell-clamshell-accel-location-base-with-sku.patch:
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
4new file mode 10064414new 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 9da13cd..d529d4d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -44,6 +44,8 @@ debian/UBUNTU-networkd-if-RA-was-implicit-do-not-await-ndisc_con.patch
44debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch44debian/UBUNTU-units-block-CAP_SYS_MODULE-units-in-containers-too.patch
45debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch45debian/UBUNTU-test-sleep-skip-test_fiemap-upon-inapproriate-ioctl-.patch
46debian/UBUNTU-Support-system-image-read-only-etc.patch46debian/UBUNTU-Support-system-image-read-only-etc.patch
47debian/timedatectl-lp1650688.patch
48debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
47debian/UBUNTU-units-disable-journald-watchdog.patch49debian/UBUNTU-units-disable-journald-watchdog.patch
48debian/UBUNTU-core-set-run-size-to-10-like-initramfs-tools-does.patch50debian/UBUNTU-core-set-run-size-to-10-like-initramfs-tools-does.patch
49Revert-namespace-be-more-careful-when-handling-namespacin.patch51Revert-namespace-be-more-careful-when-handling-namespacin.patch

Subscribers

People subscribed via source and target branches