bus-unit-util: warn and ignore assignment of deprecated properties

With 5da476ac77, we refused to set the
properties, but this relaxes the behavior, and now commands warn and
ignore the assignment.

Also, assignment of CPUAccounting property is now warned and ignored,
which is deprecated by 29da53dde3.

Prompted by https://github.com/systemd/systemd/pull/37665#discussion_r2115676993
This commit is contained in:
Yu Watanabe
2025-05-31 04:30:43 +09:00
committed by Zbigniew Jędrzejewski-Szmek
parent cb109e00c4
commit add1bc28d3

View File

@@ -71,6 +71,11 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
&u->job_path);
}
static int warn_deprecated(const char *field, const char *eq) {
log_warning("D-Bus property %s is deprecated, ignoring assignment: %s=%s", field, field, eq);
return 1;
}
#define DEFINE_BUS_APPEND_PARSE_PTR(bus_type, cast_type, type, parse_func) \
static int bus_append_##parse_func( \
sd_bus_message *m, \
@@ -590,8 +595,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return 1;
}
if (STR_IN_SET(field, "CPUAccounting",
"MemoryAccounting",
if (STR_IN_SET(field, "MemoryAccounting",
"MemoryZSwapWriteback",
"IOAccounting",
"TasksAccounting",
@@ -1029,6 +1033,19 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
* means use the default memory pressure duration from oomd.conf. */
return bus_append_parse_sec_rename(m, field, isempty(eq) ? "infinity" : eq);
if (STR_IN_SET(field,
"MemoryLimit",
"CPUShares",
"StartupCPUShares",
"BlockIOAccounting",
"BlockIOWeight",
"StartupBlockIOWeight",
"BlockIODeviceWeight",
"BlockIOReadBandwidth",
"BlockIOWriteBandwidth",
"CPUAccounting"))
return warn_deprecated(field, eq);
return 0;
}