return 0;
}
+static int can_set_coredump_receive(sd_bus *bus) {
+ _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
+ _cleanup_free_ char *path = NULL;
+ int b, r;
+
+ assert(bus);
+
+ path = unit_dbus_path_from_name(SPECIAL_INIT_SCOPE);
+ if (!path)
+ return log_oom();
+
+ r = sd_bus_get_property_trivial(
+ bus,
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Scope",
+ "CoredumpReceive",
+ &e,
+ 'b', &b);
+ if (r < 0 && !sd_bus_error_has_names(&e, SD_BUS_ERROR_UNKNOWN_PROPERTY, SD_BUS_ERROR_PROPERTY_READ_ONLY))
+ log_warning_errno(r, "Failed to determine if CoredumpReceive= can be set, assuming it cannot be: %s",
+ bus_error_message(&e, r));
+
+ return r >= 0;
+}
+
int register_machine(
sd_bus *bus,
const char *machine_name,
mounts,
n_mounts,
kill_signal,
- start_mode == START_BOOT);
+ start_mode == START_BOOT && can_set_coredump_receive(bus) > 0);
if (r < 0)
return r;
description = strjoina("Container ", machine_name);
- if (allow_pidfd) {
- _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
- r = pidref_set_pid(&pidref, pid);
- if (r < 0)
- return log_error_errno(r, "Failed to allocate PID reference: %m");
+ _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+ r = pidref_set_pid(&pidref, pid);
+ if (r < 0)
+ return log_error_errno(r, "Failed to allocate PID reference: %m");
- r = bus_append_scope_pidref(m, &pidref);
- } else
- r = sd_bus_message_append(m, "(sv)", "PIDs", "au", 1, pid);
+ r = bus_append_scope_pidref(m, &pidref, allow_pidfd);
if (r < 0)
return bus_log_create_error(r);
mounts,
n_mounts,
kill_signal,
- start_mode == START_BOOT);
+ start_mode == START_BOOT && can_set_coredump_receive(bus) > 0);
if (r < 0)
return r;
if (r < 0)
return bus_log_parse_error(r);
- r = bus_wait_for_jobs_one(w, object, false, NULL);
+ r = bus_wait_for_jobs_one(
+ w,
+ object,
+ BUS_WAIT_JOBS_LOG_ERROR,
+ /* extra_args= */ NULL);
if (r < 0)
return r;