summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-01 17:32:54 +0200
committerLennart Poettering <lennart@poettering.net>2018-06-11 12:53:12 +0200
commitfd1e3fd8defc280595b98d9f60047d8953251ec8 (patch)
tree61a6d0a4fc2412c14cbf85280399f34e735e5e0a
parente49da001c466d0d70ec5fb727bb6b886ba595c0f (diff)
downloadsystemd-fd1e3fd8defc280595b98d9f60047d8953251ec8.tar.gz
core: use bus_unit_validate_load_state() for generating LoadError unit bus property
The load_error is only valid in some load_state cases, lets generate prettier messages for other cases too, by reusing the bus_unit_validate_load_state() call which does jus that. Clients (such as systemctl) ignored LoadError unles LoadState was "error" before. With this change they could even show LoadError in other cases and it would show a useful name.
-rw-r--r--src/core/dbus-unit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 84065ac08c..a728dbe670 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -271,16 +271,18 @@ static int property_get_load_error(
sd_bus_error *error) {
_cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
- int *n = userdata;
+ Unit *u = userdata;
+ int r;
assert(bus);
assert(reply);
- assert(n);
+ assert(u);
- if (*n != 0)
- sd_bus_error_set_errno(&e, *n);
+ r = bus_unit_validate_load_state(u, &e);
+ if (r < 0)
+ return sd_bus_message_append(reply, "(ss)", e.name, e.message);
- return sd_bus_message_append(reply, "(ss)", e.name, e.message);
+ return sd_bus_message_append(reply, "(ss)", NULL, NULL);
}
static int bus_verify_manage_units_async_full(
@@ -629,7 +631,7 @@ const sd_bus_vtable bus_unit_vtable[] = {
BUS_PROPERTY_DUAL_TIMESTAMP("AssertTimestamp", offsetof(Unit, assert_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Conditions", "a(sbbsi)", property_get_conditions, offsetof(Unit, conditions), 0),
SD_BUS_PROPERTY("Asserts", "a(sbbsi)", property_get_conditions, offsetof(Unit, asserts), 0),
- SD_BUS_PROPERTY("LoadError", "(ss)", property_get_load_error, offsetof(Unit, load_error), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("LoadError", "(ss)", property_get_load_error, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Transient", "b", bus_property_get_bool, offsetof(Unit, transient), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Perpetual", "b", bus_property_get_bool, offsetof(Unit, perpetual), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StartLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Unit, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST),