Commit 24412cfc authored by Michael Vogt's avatar Michael Vogt Committed by Balint Reczey
Browse files

Import Debian changes 237-3ubuntu10.16

systemd (237-3ubuntu10.16) bionic; urgency=medium

  * d/p/Support-system-image-read-only-etc.patch:
    - re-add support for /etc/writable for core18 (LP: #1778936)
  * d/p/fix-race-daemon-reload-8803.patch:
    - backport systemd upstream PR#8803 to fix race when doing
      systemctl and systemctl daemon-reload at the same time
      LP: #1819728
parent 282faf45
systemd (237-3ubuntu10.16) bionic; urgency=medium
* d/p/Support-system-image-read-only-etc.patch:
- re-add support for /etc/writable for core18 (LP: #1778936)
* d/p/fix-race-daemon-reload-8803.patch:
- backport systemd upstream PR#8803 to fix race when doing
systemctl and systemctl daemon-reload at the same time
LP: #1819728
-- Michael Vogt <michael.vogt@ubuntu.com> Wed, 13 Mar 2019 07:42:11 +0100
systemd (237-3ubuntu10.15) bionic; urgency=medium
[ Victor Tapia ]
......
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Sat, 26 Apr 2014 23:49:32 +0200
Subject: Support system-image read-only /etc
On Ubuntu Phone with readonly /etc we symlink
/etc/{adjtime,localtime,timezone,hostname,machine-info} to /etc/writable/, so
we need to update those files instead if the original files are symlinks into
/etc/writable/.
Forwarded: OMGno, this is a rather nasty hack until we fix system-image to get a writable /etc
Bug-Ubuntu: https://launchpad.net/bugs/1227520
---
src/hostname/hostnamed.c | 28 ++++++++++++++++++++++++----
src/timedate/timedated.c | 31 +++++++++++++++++++++++++------
2 files changed, 49 insertions(+), 10 deletions(-)
Index: systemd-237/src/hostname/hostnamed.c
===================================================================
--- systemd-237.orig/src/hostname/hostnamed.c
+++ systemd-237/src/hostname/hostnamed.c
@@ -31,6 +31,7 @@
#include "hostname-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "fs-util.h"
#include "selinux-util.h"
#include "strv.h"
#include "user-util.h"
@@ -76,6 +77,25 @@ static void context_free(Context *c) {
bus_verify_polkit_async_registry_free(c->polkit_registry);
}
+/* 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_buf[PATH_MAX];
+ _cleanup_free_ char *realfile = NULL;
+ const char *result = path;
+ int orig_errno = errno;
+
+ r = readlink_and_make_absolute(path, &realfile);
+ if (r >= 0 && startswith(realfile, "/etc/writable")) {
+ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
+ result = realfile_buf;
+ }
+
+ errno = orig_errno;
+ return result;
+}
+
static int context_read_data(Context *c) {
int r;
struct utsname u;
@@ -303,12 +323,12 @@ static int context_write_data_static_hos
if (isempty(c->data[PROP_STATIC_HOSTNAME])) {
- if (unlink("/etc/hostname") < 0)
+ if (unlink(writable_filename("/etc/hostname")) < 0)
return errno == ENOENT ? 0 : -errno;
return 0;
}
- return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
+ return write_string_file_atomic_label(writable_filename("/etc/hostname"), c->data[PROP_STATIC_HOSTNAME]);
}
static int context_write_data_machine_info(Context *c) {
@@ -354,13 +374,13 @@ static int context_write_data_machine_in
}
if (strv_isempty(l)) {
- if (unlink("/etc/machine-info") < 0)
+ if (unlink(writable_filename("/etc/machine-info")) < 0)
return errno == ENOENT ? 0 : -errno;
return 0;
}
- return write_env_file_label("/etc/machine-info", l);
+ return write_env_file_label(writable_filename("/etc/machine-info"), l);
}
static int property_get_icon_name(
Index: systemd-237/src/timedate/timedated.c
===================================================================
--- systemd-237.orig/src/timedate/timedated.c
+++ systemd-237/src/timedate/timedated.c
@@ -82,6 +82,25 @@ static int context_read_data(Context *c)
return 0;
}
+/* 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_buf[PATH_MAX];
+ _cleanup_free_ char *realfile = NULL;
+ const char *result = path;
+ int orig_errno = errno;
+
+ r = readlink_and_make_absolute(path, &realfile);
+ if (r >= 0 && startswith(realfile, "/etc/writable")) {
+ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
+ result = realfile_buf;
+ }
+
+ errno = orig_errno;
+ return result;
+}
+
static int context_write_data_timezone(Context *c) {
_cleanup_free_ char *p = NULL;
int r = 0;
@@ -90,10 +109,10 @@ static int context_write_data_timezone(C
assert(c);
if (isempty(c->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;
@@ -103,12 +122,12 @@ static int context_write_data_timezone(C
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("/etc/timezone", c->zone, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
+ if (stat(writable_filename("/etc/timezone"), &st) == 0 && S_ISREG(st.st_mode)) {
+ r = write_string_file(writable_filename("/etc/timezone"), c->zone, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
if (r < 0)
return r;
}
@@ -174,7 +193,7 @@ static int context_write_data_local_rtc(
*(char*) mempcpy(stpcpy(stpcpy(mempcpy(w, s, a), prepend), c->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;
Index: systemd-237/src/core/job.c
===================================================================
--- systemd-237.orig/src/core/job.c
+++ systemd-237/src/core/job.c
@@ -57,6 +57,7 @@ Job* job_new_raw(Unit *unit) {
j->manager = unit->manager;
j->unit = unit;
j->type = _JOB_TYPE_INVALID;
+ j->reloaded = false;
return j;
}
@@ -78,7 +79,7 @@ Job* job_new(Unit *unit, JobType type) {
return j;
}
-void job_free(Job *j) {
+void job_unlink(Job *j) {
assert(j);
assert(!j->installed);
assert(!j->transaction_prev);
@@ -86,16 +87,33 @@ void job_free(Job *j) {
assert(!j->subject_list);
assert(!j->object_list);
- if (j->in_run_queue)
+ if (j->in_run_queue) {
LIST_REMOVE(run_queue, j->manager->run_queue, j);
+ j->in_run_queue = false;
+ }
- if (j->in_dbus_queue)
+ if (j->in_dbus_queue) {
LIST_REMOVE(dbus_queue, j->manager->dbus_job_queue, j);
+ j->in_dbus_queue = false;
+ }
- if (j->in_gc_queue)
+ if (j->in_gc_queue) {
LIST_REMOVE(gc_queue, j->manager->gc_job_queue, j);
+ j->in_gc_queue = false;
+ }
- sd_event_source_unref(j->timer_event_source);
+ j->timer_event_source = sd_event_source_unref(j->timer_event_source);
+}
+
+void job_free(Job *j) {
+ assert(j);
+ assert(!j->installed);
+ assert(!j->transaction_prev);
+ assert(!j->transaction_next);
+ assert(!j->subject_list);
+ assert(!j->object_list);
+
+ job_unlink(j);
sd_bus_track_unref(j->bus_track);
strv_free(j->deserialized_clients);
@@ -255,6 +273,7 @@ int job_install_deserialized(Job *j) {
*pj = j;
j->installed = true;
+ j->reloaded = true;
if (j->state == JOB_RUNNING)
j->unit->manager->n_running_jobs++;
@@ -849,6 +868,19 @@ static void job_fail_dependencies(Unit *
}
}
+static int job_save_pending_finished_job(Job *j) {
+ int r;
+
+ assert(j);
+
+ r = set_ensure_allocated(&j->manager->pending_finished_jobs, NULL);
+ if (r < 0)
+ return r;
+
+ job_unlink(j);
+ return set_put(j->manager->pending_finished_jobs, j);
+}
+
int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool already) {
Unit *u;
Unit *other;
@@ -888,7 +920,12 @@ int job_finish_and_invalidate(Job *j, Jo
j->manager->n_failed_jobs++;
job_uninstall(j);
- job_free(j);
+ /* Remember jobs started before the reload */
+ if (MANAGER_IS_RELOADING(j->manager) && j->reloaded) {
+ if (job_save_pending_finished_job(j) < 0)
+ job_free(j);
+ } else
+ job_free(j);
/* Fail depending jobs on failure */
if (result != JOB_DONE && recursive) {
Index: systemd-237/src/core/job.h
===================================================================
--- systemd-237.orig/src/core/job.h
+++ systemd-237/src/core/job.h
@@ -174,10 +174,12 @@ struct Job {
bool irreversible:1;
bool in_gc_queue:1;
bool ref_by_private_bus:1;
+ bool reloaded:1;
};
Job* job_new(Unit *unit, JobType type);
Job* job_new_raw(Unit *unit);
+void job_unlink(Job *job);
void job_free(Job *job);
Job* job_install(Job *j);
int job_install_deserialized(Job *j);
Index: systemd-237/src/core/manager.c
===================================================================
--- systemd-237.orig/src/core/manager.c
+++ systemd-237/src/core/manager.c
@@ -3043,6 +3043,17 @@ finish:
return r;
}
+static void manager_flush_finished_jobs(Manager *m) {
+ Job *j;
+
+ while ((j = set_steal_first(m->pending_finished_jobs))) {
+ bus_job_send_removed_signal(j);
+ job_free(j);
+ }
+
+ m->pending_finished_jobs = set_free(m->pending_finished_jobs);
+}
+
int manager_reload(Manager *m) {
int r, q;
_cleanup_fclose_ FILE *f = NULL;
@@ -3146,6 +3157,9 @@ int manager_reload(Manager *m) {
assert(m->n_reloading > 0);
m->n_reloading--;
+ if (!MANAGER_IS_RELOADING(m))
+ manager_flush_finished_jobs(m);
+
m->send_reloading_done = true;
return r;
Index: systemd-237/src/core/manager.h
===================================================================
--- systemd-237.orig/src/core/manager.h
+++ systemd-237/src/core/manager.h
@@ -305,6 +305,9 @@ struct Manager {
/* non-zero if we are reloading or reexecuting, */
int n_reloading;
+ /* A set which contains all jobs that started before reload and finished
+ * during it */
+ Set *pending_finished_jobs;
unsigned n_installed_jobs;
unsigned n_failed_jobs;
......@@ -97,3 +97,5 @@ CVE-2019-6454.patch
sd-bus-if-we-receive-an-invalid-dbus-message-ignore-.patch
journal-do-not-remove-multiple-spaces-after-identifi.patch
stop-mount-error-propagation.patch
fix-race-daemon-reload-8803.patch
Support-system-image-read-only-etc.patch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment