From 7db0ff874021286b1c717285ee009166b7bc26ea Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 25 Sep 2013 13:14:01 +0200 Subject: [PATCH] Add 0013-Support-phablet-etc-writable.patch On Ubuntu Phone with readonly /etc we symlink /etc/{adjtime,localtime,timezone} to /etc/writable/, so we need to update those files instead if the original files are symlinks into /etc/writable/. (LP: #1227520) --- debian/changelog | 9 +++ .../0013-Support-phablet-etc-writable.patch | 94 ++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 104 insertions(+) create mode 100644 debian/patches/0013-Support-phablet-etc-writable.patch diff --git a/debian/changelog b/debian/changelog index c817f61..812211a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +systemd (204-0ubuntu13) UNRELEASED; urgency=low + + * Add 0013-Support-phablet-etc-writable.patch: On Ubuntu Phone with readonly + /etc we symlink /etc/{adjtime,localtime,timezone} to /etc/writable/, so we + need to update those files instead if the original files are symlinks into + /etc/writable/. (LP: #1227520) + + -- Martin Pitt Wed, 25 Sep 2013 13:13:35 +0200 + systemd (204-0ubuntu12) saucy; urgency=low * SECURITY UPDATE: possible privilege escalation via policykit UID lookup diff --git a/debian/patches/0013-Support-phablet-etc-writable.patch b/debian/patches/0013-Support-phablet-etc-writable.patch new file mode 100644 index 0000000..fb95a81 --- /dev/null +++ b/debian/patches/0013-Support-phablet-etc-writable.patch @@ -0,0 +1,94 @@ +Description: On Ubuntu Phone with readonly /etc we symlink /etc/{adjtime,localtime,timezone} to /etc/writable/, so we need to update those files instead if the original files are symlinks into /etc/writable/. +Author: Martin Pitt +Forwarded: OMGno, this is a rather nasty hack until we get a clean solution for an /etc overlay +Bug-Ubuntu: https://launchpad.net/bugs/1227520 + +Index: systemd/src/timedate/timedated.c +=================================================================== +--- systemd.orig/src/timedate/timedated.c 2013-09-25 12:14:57.057609132 +0200 ++++ systemd/src/timedate/timedated.c 2013-09-25 13:07:14.009760951 +0200 +@@ -105,6 +105,25 @@ + tz.local_rtc = false; + } + ++/* Hack for Ubuntu phone: check if path is an existing symlink to ++ * /etc/writable; if it is, update that instead */ ++static const char* writable_filename(const char *path) { ++ ssize_t r; ++ static char realfile[PATH_MAX]; ++ const char *result = path; ++ int orig_errno = errno; ++ ++ r = readlink(path, realfile, sizeof(realfile) - 1); ++ ++ if (r > 0 && (size_t) r < sizeof(realfile) && startswith(realfile, "/etc/writable")) { ++ realfile[r] = '\0'; ++ result = realfile; ++ } ++ ++ errno = orig_errno; ++ return result; ++} ++ + static bool valid_timezone(const char *name) { + const char *p; + char *t; +@@ -159,7 +178,7 @@ + + free_data(); + +- r = readlink_malloc("/etc/localtime", &t); ++ r = readlink_malloc(writable_filename("/etc/localtime"), &t); + if (r < 0) { + if (r == -EINVAL) + log_warning("/etc/localtime should be a symbolic link to a timezone data file in /usr/share/zoneinfo/."); +@@ -207,25 +226,25 @@ + struct stat st; + + if (!tz.zone) { +- if (unlink("/etc/localtime") < 0 && errno != ENOENT) ++ if (unlink(writable_filename("/etc/localtime")) < 0 && errno != ENOENT) + r = -errno; + +- if (unlink("/etc/timezone") < 0 && errno != ENOENT) ++ if (unlink(writable_filename("/etc/timezone")) < 0 && errno != ENOENT) + r = -errno; + + return r; + } + +- p = strappend("../usr/share/zoneinfo/", tz.zone); ++ p = strappend("/usr/share/zoneinfo/", tz.zone); + if (!p) + return log_oom(); + +- r = symlink_atomic(p, "/etc/localtime"); ++ r = symlink_atomic(p, writable_filename("/etc/localtime")); + if (r < 0) + return r; + +- if (stat("/etc/timezone", &st) == 0 && S_ISREG(st.st_mode)) { +- r = write_string_file_atomic("/etc/timezone", tz.zone); ++ if (stat(writable_filename("/etc/timezone"), &st) == 0 && S_ISREG(st.st_mode)) { ++ r = write_string_file_atomic(writable_filename("/etc/timezone"), tz.zone); + if (r < 0) + return r; + } +@@ -276,7 +295,7 @@ + *(char*) mempcpy(stpcpy(mempcpy(w, s, a), tz.local_rtc ? "LOCAL" : "UTC"), e, b) = 0; + + if (streq(w, NULL_ADJTIME_UTC)) { +- if (unlink("/etc/adjtime") < 0) ++ if (unlink(writable_filename("/etc/adjtime")) < 0) + if (errno != ENOENT) + return -errno; + +@@ -284,7 +303,7 @@ + } + } + label_init("/etc"); +- return write_string_file_atomic_label("/etc/adjtime", w); ++ return write_string_file_atomic_label(writable_filename("/etc/adjtime"), w); + } + + static char** get_ntp_services(void) { diff --git a/debian/patches/series b/debian/patches/series index beadf17..7881536 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -22,3 +22,4 @@ 0025-login-monitor-no-machine.patch 0026-always-probe-cpu-support-drivers.patch 0027-CVE-2013-4327.patch +0013-Support-phablet-etc-writable.patch -- 1.8.3.2