]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-unit-util: warn and ignore assignment of deprecated properties
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 30 May 2025 19:30:43 +0000 (04:30 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 3 Jun 2025 13:31:05 +0000 (15:31 +0200)
With 5da476ac7728b91ad3a49c1b126b3559b4fbeed8, 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 29da53dde32a0097134f6c3ba5fb5220dd6e5423.

Prompted by https://github.com/systemd/systemd/pull/37665#discussion_r2115676993

src/shared/bus-unit-util.c

index 328caca3396e2c39746c70dc370da9890b971a20..1e28622668c2061530aca8345de0bce009db0bd7 100644 (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;
 }