summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bus-proxyd/proxy.c12
-rw-r--r--src/core/execute.c8
-rw-r--r--src/core/load-fragment.c2
-rw-r--r--src/core/main.c4
-rw-r--r--src/core/unit.c3
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c188
-rw-r--r--src/import/pull-tar.c8
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c6
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c1
-rw-r--r--src/libsystemd/sd-bus/bus-message.c4
-rw-r--r--src/login/logind-dbus.c36
-rw-r--r--src/login/logind-session.c5
-rw-r--r--src/login/logind.c4
-rw-r--r--src/machine/machine.c36
-rw-r--r--src/machine/machine.h3
-rw-r--r--src/machine/machined-dbus.c46
-rw-r--r--src/machine/machined.c10
-rw-r--r--src/udev/udev-builtin-blkid.c5
18 files changed, 190 insertions, 191 deletions
diff --git a/src/bus-proxyd/proxy.c b/src/bus-proxyd/proxy.c
index df361ac400..88800f5e7f 100644
--- a/src/bus-proxyd/proxy.c
+++ b/src/bus-proxyd/proxy.c
@@ -770,19 +770,21 @@ static int proxy_process_destination_to_local(Proxy *p) {
return r;
/* If the peer tries to send a reply and it is
- * rejected with EPERM by the kernel, we ignore the
+ * rejected with EBADSLT by the kernel, we ignore the
* error. This catches cases where the original
* method-call didn't had EXPECT_REPLY set, but the
* proxy-peer still sends a reply. This is allowed in
* dbus1, but not in kdbus. We don't want to track
* reply-windows in the proxy, so we simply ignore
- * EPERM for all replies. The only downside is, that
+ * EBADSLT for all replies. The only downside is, that
* callers are no longer notified if their replies are
* dropped. However, this is equivalent to the
* caller's timeout to expire, so this should be
* acceptable. Nobody sane sends replies without a
* matching method-call, so nobody should care. */
- if (r == -EPERM && m->reply_cookie > 0)
+
+ /* FIXME: remove -EPERM when kdbus is updated */
+ if ((r == -EPERM || r == -EBADSLT) && m->reply_cookie > 0)
return 1;
/* Return the error to the client, if we can */
@@ -863,8 +865,8 @@ static int proxy_process_local_to_destination(Proxy *p) {
if (r == -EREMCHG)
continue;
- /* see above why EPERM is ignored for replies */
- if (r == -EPERM && m->reply_cookie > 0)
+ /* see above why EBADSLT is ignored for replies */
+ if ((r == -EPERM || r == -EBADSLT) && m->reply_cookie > 0)
return 1;
synthetic_reply_method_errnof(m, r, "Failed to forward message we got from local: %m");
diff --git a/src/core/execute.c b/src/core/execute.c
index 125cb0dbd4..3820165241 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1554,7 +1554,13 @@ static int exec_child(
return -ENOMEM;
}
- r = mkdir_safe_label(p, context->runtime_directory_mode, uid, gid);
+ r = mkdir_p_label(p, context->runtime_directory_mode);
+ if (r < 0) {
+ *exit_status = EXIT_RUNTIME_DIRECTORY;
+ return r;
+ }
+
+ r = chmod_and_chown(p, context->runtime_directory_mode, uid, gid);
if (r < 0) {
*exit_status = EXIT_RUNTIME_DIRECTORY;
return r;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index ba73cc410e..299172123e 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1986,7 +1986,7 @@ int config_parse_environ(const char *unit,
return log_oom();
FOREACH_WORD_QUOTED(word, l, k, state) {
- _cleanup_free_ char *n;
+ _cleanup_free_ char *n = NULL;
char **x;
r = cunescape_length(word, l, 0, &n);
diff --git a/src/core/main.c b/src/core/main.c
index a66fb18418..87b97aa883 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1785,7 +1785,7 @@ int main(int argc, char *argv[]) {
case MANAGER_REEXECUTE:
if (prepare_reexecute(m, &arg_serialization, &fds, false) < 0) {
- error_message = "Failed to prepare for reexection";
+ error_message = "Failed to prepare for reexecution";
goto finish;
}
@@ -1801,7 +1801,7 @@ int main(int argc, char *argv[]) {
if (!switch_root_init)
if (prepare_reexecute(m, &arg_serialization, &fds, true) < 0) {
- error_message = "Failed to prepare for reexection";
+ error_message = "Failed to prepare for reexecution";
goto finish;
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 6cc5824eb2..43a5ca1064 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -478,11 +478,12 @@ void unit_free(Unit *u) {
if (u->manager->n_reloading <= 0)
unit_remove_transient(u);
- sd_bus_slot_unref(u->match_bus_slot);
bus_unit_send_removed_signal(u);
unit_done(u);
+ sd_bus_slot_unref(u->match_bus_slot);
+
unit_free_requires_mounts_for(u);
SET_FOREACH(t, u->names, i)
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 9d889c17d8..0a34f86be7 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -240,82 +240,6 @@ static int add_mount(
return 0;
}
-static int add_automount(
- const char *id,
- const char *what,
- const char *where,
- const char *fstype,
- bool rw,
- const char *options,
- const char *description,
- usec_t timeout) {
-
- _cleanup_free_ char *unit = NULL, *lnk = NULL;
- _cleanup_free_ char *opt, *p = NULL;
- _cleanup_fclose_ FILE *f = NULL;
- int r;
-
- assert(id);
- assert(where);
- assert(description);
-
- if (options)
- opt = strjoin(options, ",noauto", NULL);
- else
- opt = strdup("noauto");
- if (!opt)
- return log_oom();
-
- r = add_mount(id,
- what,
- where,
- fstype,
- rw,
- opt,
- description,
- NULL);
- if (r < 0)
- return r;
-
- r = unit_name_from_path(where, ".automount", &unit);
- if (r < 0)
- return log_error_errno(r, "Failed to generate unit name: %m");
-
- p = strjoin(arg_dest, "/", unit, NULL);
- if (!p)
- return log_oom();
-
- f = fopen(p, "wxe");
- if (!f)
- return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
-
- fprintf(f,
- "# Automatically generated by systemd-gpt-auto-generator\n\n"
- "[Unit]\n"
- "Description=%s\n"
- "Documentation=man:systemd-gpt-auto-generator(8)\n"
- "[Automount]\n"
- "Where=%s\n"
- "TimeoutIdleSec=%lld\n",
- description,
- where,
- (unsigned long long)timeout / USEC_PER_SEC);
-
- r = fflush_and_check(f);
- if (r < 0)
- return log_error_errno(r, "Failed to write unit file %s: %m", p);
-
- lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL);
- if (!lnk)
- return log_oom();
- mkdir_parents_label(lnk, 0755);
-
- if (symlink(p, lnk) < 0)
- return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
-
- return 0;
-}
-
static bool path_is_busy(const char *where) {
int r;
@@ -441,8 +365,84 @@ static int add_swap(const char *path) {
return 0;
}
-static int add_boot(const char *what) {
#ifdef ENABLE_EFI
+static int add_automount(
+ const char *id,
+ const char *what,
+ const char *where,
+ const char *fstype,
+ bool rw,
+ const char *options,
+ const char *description,
+ usec_t timeout) {
+
+ _cleanup_free_ char *unit = NULL, *lnk = NULL;
+ _cleanup_free_ char *opt, *p = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
+ int r;
+
+ assert(id);
+ assert(where);
+ assert(description);
+
+ if (options)
+ opt = strjoin(options, ",noauto", NULL);
+ else
+ opt = strdup("noauto");
+ if (!opt)
+ return log_oom();
+
+ r = add_mount(id,
+ what,
+ where,
+ fstype,
+ rw,
+ opt,
+ description,
+ NULL);
+ if (r < 0)
+ return r;
+
+ r = unit_name_from_path(where, ".automount", &unit);
+ if (r < 0)
+ return log_error_errno(r, "Failed to generate unit name: %m");
+
+ p = strjoin(arg_dest, "/", unit, NULL);
+ if (!p)
+ return log_oom();
+
+ f = fopen(p, "wxe");
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
+
+ fprintf(f,
+ "# Automatically generated by systemd-gpt-auto-generator\n\n"
+ "[Unit]\n"
+ "Description=%s\n"
+ "Documentation=man:systemd-gpt-auto-generator(8)\n"
+ "[Automount]\n"
+ "Where=%s\n"
+ "TimeoutIdleSec=%lld\n",
+ description,
+ where,
+ (unsigned long long)timeout / USEC_PER_SEC);
+
+ r = fflush_and_check(f);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write unit file %s: %m", p);
+
+ lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL);
+ if (!lnk)
+ return log_oom();
+ mkdir_parents_label(lnk, 0755);
+
+ if (symlink(p, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
+
+ return 0;
+}
+
+static int add_boot(const char *what) {
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
const char *fstype = NULL, *uuid = NULL;
sd_id128_t id, type_id;
@@ -532,10 +532,12 @@ static int add_boot(const char *what) {
120 * USEC_PER_SEC);
return r;
+}
#else
+static int add_boot(const char *what) {
return 0;
-#endif
}
+#endif
static int enumerate_partitions(dev_t devnum) {
@@ -616,9 +618,12 @@ static int enumerate_partitions(dev_t devnum) {
errno = 0;
r = blkid_do_safeprobe(b);
- if (r == -2 || r == 1) /* no result or uncertain */
+ if (r == 1)
+ return 0; /* no results */
+ else if (r == -2) {
+ log_warning("%s: probe gave ambiguous results, ignoring", node);
return 0;
- else if (r != 0)
+ } else if (r != 0)
return log_error_errno(errno ?: EIO, "%s: failed to probe: %m", node);
errno = 0;
@@ -666,7 +671,6 @@ static int enumerate_partitions(dev_t devnum) {
blkid_partition pp;
dev_t qn;
int nr;
- unsigned long long flags;
q = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
if (!q)
@@ -690,13 +694,6 @@ static int enumerate_partitions(dev_t devnum) {
if (!pp)
continue;
- flags = blkid_partition_get_flags(pp);
-
- /* Ignore partitions that are not marked for automatic
- * mounting on discovery */
- if (flags & GPT_FLAG_NO_AUTO)
- continue;
-
nr = blkid_partition_get_partno(pp);
if (nr < 0)
continue;
@@ -709,6 +706,11 @@ static int enumerate_partitions(dev_t devnum) {
continue;
if (sd_id128_equal(type_id, GPT_SWAP)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
if (flags & GPT_FLAG_READ_ONLY) {
log_debug("%s marked as read-only swap partition, which is bogus. Ignoring.", subnode);
@@ -732,6 +734,11 @@ static int enumerate_partitions(dev_t devnum) {
return log_oom();
} else if (sd_id128_equal(type_id, GPT_HOME)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We only care for the first /home partition */
if (home && nr >= home_nr)
@@ -745,6 +752,11 @@ static int enumerate_partitions(dev_t devnum) {
return log_oom();
} else if (sd_id128_equal(type_id, GPT_SRV)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We only care for the first /srv partition */
if (srv && nr >= srv_nr)
diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c
index a6605d248f..71b8908a58 100644
--- a/src/import/pull-tar.c
+++ b/src/import/pull-tar.c
@@ -127,13 +127,7 @@ int tar_pull_new(
i->grow_machine_directory = path_startswith(i->image_root, "/var/lib/machines");
- if (event)
- i->event = sd_event_ref(event);
- else {
- r = sd_event_default(&i->event);
- if (r < 0)
- return r;
- }
+ i->event = sd_event_ref(event);
r = curl_glue_new(&i->glue, i->event);
if (r < 0)
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index e0874aebad..f5b9e22589 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -954,7 +954,7 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
}
for (i = 0; i <= DHCP_OPTION_PRIVATE_LAST - DHCP_OPTION_PRIVATE_BASE; i++) {
- uint8_t *data;
+ _cleanup_free_ uint8_t *data = NULL;
size_t len;
if (!options[i])
@@ -965,10 +965,8 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
return r;
r = dhcp_lease_insert_private_option(lease, DHCP_OPTION_PRIVATE_BASE + i, data, len);
- if (r < 0) {
- free(data);
+ if (r < 0)
return r;
- }
}
*ret = lease;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index d72535b8bc..22a43c4542 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -776,6 +776,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
case KDBUS_ITEM_FDS:
case KDBUS_ITEM_SECLABEL:
+ case KDBUS_ITEM_BLOOM_FILTER:
break;
default:
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 006e4a2b58..94427ed664 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -608,8 +608,8 @@ static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
m->header = (struct bus_header*) ((uint8_t*) m + ALIGN(sizeof(struct sd_bus_message)));
m->header->endian = BUS_NATIVE_ENDIAN;
m->header->type = type;
- m->header->version = bus ? bus->message_version : 1;
- m->allow_fds = !bus || bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
+ m->header->version = bus->message_version;
+ m->allow_fds = bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
m->root_container.need_offsets = BUS_MESSAGE_IS_GVARIANT(m);
m->bus = sd_bus_ref(bus);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 1647bb293a..992a9f5b4a 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2511,7 +2511,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
if (r < 0) {
bus_log_parse_error(r);
- return r;
+ return 0;
}
if (m->action_job && streq(m->action_job, path)) {
@@ -2520,8 +2520,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
/* Tell people that they now may take a lock again */
send_prepare_for(m, m->action_what, false);
- free(m->action_job);
- m->action_job = NULL;
+ m->action_job = mfree(m->action_job);
m->action_unit = NULL;
m->action_what = 0;
return 0;
@@ -2530,10 +2529,8 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
session = hashmap_get(m->session_units, unit);
if (session) {
- if (streq_ptr(path, session->scope_job)) {
- free(session->scope_job);
- session->scope_job = NULL;
- }
+ if (streq_ptr(path, session->scope_job))
+ session->scope_job = mfree(session->scope_job);
session_jobs_reply(session, unit, result);
@@ -2545,19 +2542,14 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
user = hashmap_get(m->user_units, unit);
if (user) {
- if (streq_ptr(path, user->service_job)) {
- free(user->service_job);
- user->service_job = NULL;
- }
+ if (streq_ptr(path, user->service_job))
+ user->service_job = mfree(user->service_job);
- if (streq_ptr(path, user->slice_job)) {
- free(user->slice_job);
- user->slice_job = NULL;
- }
+ if (streq_ptr(path, user->slice_job))
+ user->slice_job = mfree(user->slice_job);
- LIST_FOREACH(sessions_by_user, session, user->sessions) {
+ LIST_FOREACH(sessions_by_user, session, user->sessions)
session_jobs_reply(session, unit, result);
- }
user_save(user);
user_add_to_gc_queue(user);
@@ -2579,7 +2571,7 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er
r = sd_bus_message_read(message, "so", &unit, &path);
if (r < 0) {
bus_log_parse_error(r);
- return r;
+ return 0;
}
session = hashmap_get(m->session_units, unit);
@@ -2611,8 +2603,10 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err
r = unit_name_from_dbus_path(path, &unit);
if (r == -EINVAL) /* not a unit */
return 0;
- if (r < 0)
- return r;
+ if (r < 0) {
+ log_oom();
+ return 0;
+ }
session = hashmap_get(m->session_units, unit);
if (session)
@@ -2637,7 +2631,7 @@ int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
bus_log_parse_error(r);
- return r;
+ return 0;
}
if (b)
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index fc92f7f73b..e75c7c042e 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -656,7 +656,6 @@ int session_stop(Session *s, bool force) {
}
int session_finalize(Session *s) {
- int r = 0;
SessionDevice *sd;
assert(s);
@@ -682,7 +681,7 @@ int session_finalize(Session *s) {
while ((sd = hashmap_first(s->devices)))
session_device_free(sd);
- unlink(s->state_file);
+ (void) unlink(s->state_file);
session_add_to_gc_queue(s);
user_add_to_gc_queue(s->user);
@@ -702,7 +701,7 @@ int session_finalize(Session *s) {
user_save(s->user);
user_send_changed(s->user, "Sessions", "Display", NULL);
- return r;
+ return 0;
}
static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *userdata) {
diff --git a/src/login/logind.c b/src/login/logind.c
index 49a2811842..cf71c0ec5a 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -907,8 +907,8 @@ static void manager_gc(Manager *m, bool drop_not_started) {
session_get_state(session) != SESSION_CLOSING)
session_stop(session, false);
- /* Normally, this should make the session busy again,
- * if it doesn't then let's get rid of it
+ /* Normally, this should make the session referenced
+ * again, if it doesn't then let's get rid of it
* immediately */
if (!session_check_gc(session, drop_not_started)) {
session_finalize(session);
diff --git a/src/machine/machine.c b/src/machine/machine.c
index ab26803683..f045159d41 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -231,11 +231,11 @@ static void machine_unlink(Machine *m) {
char *sl;
sl = strjoina("/run/systemd/machines/unit:", m->unit);
- unlink(sl);
+ (void) unlink(sl);
}
if (m->state_file)
- unlink(m->state_file);
+ (void) unlink(m->state_file);
}
int machine_load(Machine *m) {
@@ -419,7 +419,19 @@ static int machine_stop_scope(Machine *m) {
}
int machine_stop(Machine *m) {
- int r = 0, k;
+ int r;
+ assert(m);
+
+ r = machine_stop_scope(m);
+
+ m->stopping = true;
+
+ machine_save(m);
+
+ return r;
+}
+
+int machine_finalize(Machine *m) {
assert(m);
if (m->started)
@@ -430,20 +442,15 @@ int machine_stop(Machine *m) {
LOG_MESSAGE("Machine %s terminated.", m->name),
NULL);
- /* Kill cgroup */
- k = machine_stop_scope(m);
- if (k < 0)
- r = k;
-
machine_unlink(m);
machine_add_to_gc_queue(m);
- if (m->started)
+ if (m->started) {
machine_send_signal(m, false);
+ m->started = false;
+ }
- m->started = false;
-
- return r;
+ return 0;
}
bool machine_check_gc(Machine *m, bool drop_not_started) {
@@ -474,8 +481,11 @@ void machine_add_to_gc_queue(Machine *m) {
MachineState machine_get_state(Machine *s) {
assert(s);
+ if (s->stopping)
+ return MACHINE_CLOSING;
+
if (s->scope_job)
- return s->started ? MACHINE_OPENING : MACHINE_CLOSING;
+ return MACHINE_OPENING;
return MACHINE_RUNNING;
}
diff --git a/src/machine/machine.h b/src/machine/machine.h
index bbe5217f65..0132b65a97 100644
--- a/src/machine/machine.h
+++ b/src/machine/machine.h
@@ -67,7 +67,6 @@ struct Machine {
char *name;
sd_id128_t id;
- MachineState state;
MachineClass class;
char *state_file;
@@ -83,6 +82,7 @@ struct Machine {
bool in_gc_queue:1;
bool started:1;
+ bool stopping:1;
sd_bus_message *create_message;
@@ -101,6 +101,7 @@ bool machine_check_gc(Machine *m, bool drop_not_started);
void machine_add_to_gc_queue(Machine *m);
int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
int machine_stop(Machine *m);
+int machine_finalize(Machine *m);
int machine_save(Machine *m);
int machine_load(Machine *m);
int machine_kill(Machine *m, KillWho who, int signo);
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 3637815fc9..08a7f58ef5 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -1116,7 +1116,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
if (r < 0) {
bus_log_parse_error(r);
- return r;
+ return 0;
}
machine = hashmap_get(m->machine_units, unit);
@@ -1124,8 +1124,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
return 0;
if (streq_ptr(path, machine->scope_job)) {
- free(machine->scope_job);
- machine->scope_job = NULL;
+ machine->scope_job = mfree(machine->scope_job);
if (machine->started) {
if (streq(result, "done"))
@@ -1137,8 +1136,9 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
machine_send_create_reply(machine, &e);
}
- } else
- machine_save(machine);
+ }
+
+ machine_save(machine);
}
machine_add_to_gc_queue(machine);
@@ -1147,7 +1147,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *unit = NULL;
- const char *path, *interface;
+ const char *path;
Manager *m = userdata;
Machine *machine;
int r;
@@ -1171,36 +1171,6 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err
if (!machine)
return 0;
- r = sd_bus_message_read(message, "s", &interface);
- if (r < 0) {
- bus_log_parse_error(r);
- return 0;
- }
-
- if (streq(interface, "org.freedesktop.systemd1.Unit")) {
- struct properties {
- char *active_state;
- char *sub_state;
- } properties = {};
-
- const struct bus_properties_map map[] = {
- { "ActiveState", "s", NULL, offsetof(struct properties, active_state) },
- { "SubState", "s", NULL, offsetof(struct properties, sub_state) },
- {}
- };
-
- r = bus_message_map_properties_changed(message, map, &properties);
- if (r < 0)
- bus_log_parse_error(r);
- else if (streq_ptr(properties.active_state, "inactive") ||
- streq_ptr(properties.active_state, "failed") ||
- streq_ptr(properties.sub_state, "auto-restart"))
- machine_release_unit(machine);
-
- free(properties.active_state);
- free(properties.sub_state);
- }
-
machine_add_to_gc_queue(machine);
return 0;
}
@@ -1224,9 +1194,7 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er
if (!machine)
return 0;
- machine_release_unit(machine);
machine_add_to_gc_queue(machine);
-
return 0;
}
@@ -1242,7 +1210,7 @@ int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
bus_log_parse_error(r);
- return r;
+ return 0;
}
if (b)
return 0;
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 9bfe2add54..1eeeaf17a5 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -247,8 +247,16 @@ void manager_gc(Manager *m, bool drop_not_started) {
LIST_REMOVE(gc_queue, m->machine_gc_queue, machine);
machine->in_gc_queue = false;
- if (!machine_check_gc(machine, drop_not_started)) {
+ /* First, if we are not closing yet, initiate stopping */
+ if (!machine_check_gc(machine, drop_not_started) &&
+ machine_get_state(machine) != MACHINE_CLOSING)
machine_stop(machine);
+
+ /* Now, the stop stop probably made this referenced
+ * again, but if it didn't, then it's time to let it
+ * go entirely. */
+ if (!machine_check_gc(machine, drop_not_started)) {
+ machine_finalize(machine);
machine_free(machine);
}
}
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c
index 1dad4476f3..b8066ea6e9 100644
--- a/src/udev/udev-builtin-blkid.c
+++ b/src/udev/udev-builtin-blkid.c
@@ -143,6 +143,11 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) {
if (sd_id128_equal(type, GPT_ESP)) {
sd_id128_t id, esp;
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We found an ESP, let's see if it matches
* the ESP we booted from. */