mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
core: allow Markers to be set using set-property
This commit is contained in:
@@ -1871,6 +1871,63 @@ static int bus_unit_set_live_property(
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* A setting that only applies to active units. We don't actually write this to /run, this state is
|
||||
* managed internally. "+foo" sets flag foo, "-foo" unsets flag foo, just "foo" resets flags to
|
||||
* foo. The last type cannot be mixed with "+" or "-". */
|
||||
|
||||
if (streq(name, "Markers")) {
|
||||
unsigned settings = 0, mask = 0;
|
||||
bool some_plus_minus = false, some_absolute = false;
|
||||
|
||||
r = sd_bus_message_enter_container(message, 'a', "s");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
for (;;) {
|
||||
const char *word;
|
||||
bool b;
|
||||
|
||||
r = sd_bus_message_read(message, "s", &word);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
if (IN_SET(word[0], '+', '-')) {
|
||||
b = word[0] == '+';
|
||||
word++;
|
||||
some_plus_minus = true;
|
||||
} else {
|
||||
b = true;
|
||||
some_absolute = true;
|
||||
}
|
||||
|
||||
UnitMarker m = unit_marker_from_string(word);
|
||||
if (m < 0)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
|
||||
"Unknown marker \"%s\".", word);
|
||||
|
||||
SET_FLAG(settings, 1u << m, b);
|
||||
SET_FLAG(mask, 1u << m, true);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (some_plus_minus && some_absolute)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING, "Bad marker syntax.");
|
||||
|
||||
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
||||
if (some_absolute)
|
||||
u->markers = settings;
|
||||
else
|
||||
u->markers = settings | (u->markers & ~mask);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2191,7 +2191,8 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
|
||||
|
||||
if (unit_dependency_from_string(field) >= 0 ||
|
||||
STR_IN_SET(field, "Documentation",
|
||||
"RequiresMountsFor"))
|
||||
"RequiresMountsFor",
|
||||
"Markers"))
|
||||
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
|
||||
|
||||
t = condition_type_from_string(field);
|
||||
|
||||
Reference in New Issue
Block a user