summaryrefslogtreecommitdiff
path: root/src/core/dbus-unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-08-16 18:07:30 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-17 07:08:37 +0900
commiteab62c01ef81adb85dbbb561b3102d1cf960f5b6 (patch)
tree6765f7aa06432a72c5f0280bf955d44e5d098ae9 /src/core/dbus-unit.c
parente4e6cfaad04d93873bc542b072eea2f34e607a01 (diff)
downloadsystemd-eab62c01ef81adb85dbbb561b3102d1cf960f5b6.tar.gz
manager: allow assignment of properties on target/swap/device units
E.g. Documentation or Markers could apply to any unit type. This already worked partially, because a direct dbus call could be made: After rebuild with the patch, but before the manager has been restarted: $ build/systemctl --user set-property dev-zram0.swap Markers=+needs-restart $ build/systemctl --user show -p Markers dev-zram0.swap Markers=needs-restart I noticed that that the rpm unit restart helper was throwing errors for target units. We should just let the Markers be set for those too, even if it doesn't do anything in the end. This way we don't need to special-case by unit type.
Diffstat (limited to 'src/core/dbus-unit.c')
-rw-r--r--src/core/dbus-unit.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 4650df4d1c..ee013e1bc5 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -2437,10 +2437,6 @@ int bus_unit_set_properties(
if (r < 0)
return r;
- if (!UNIT_VTABLE(u)->bus_set_property)
- return sd_bus_error_setf(error, SD_BUS_ERROR_PROPERTY_READ_ONLY,
- "Objects of this type do not support setting properties.");
-
r = sd_bus_message_enter_container(message, 'v', NULL);
if (r < 0)
return r;
@@ -2448,7 +2444,10 @@ int bus_unit_set_properties(
/* If not for real, then mask out the two target flags */
f = for_real ? flags : (flags & ~(UNIT_RUNTIME|UNIT_PERSISTENT));
- r = UNIT_VTABLE(u)->bus_set_property(u, name, message, f, error);
+ if (UNIT_VTABLE(u)->bus_set_property)
+ r = UNIT_VTABLE(u)->bus_set_property(u, name, message, f, error);
+ else
+ r = 0;
if (r == 0 && u->transient && u->load_state == UNIT_STUB)
r = bus_unit_set_transient_property(u, name, message, f, error);
if (r == 0)