shared: don't exclude valid min/max values for cgroup weight fields
1 and 10000 are valid cgroup weight values, but the condition was
incorrectly excluding them:
$ echo '{"userName":"crashhostarray","cpuWeight":1}' | userdbctl -F -
<stdin>:1:42: JSON field 'cpuWeight' is not in valid range 1…10000.
$ echo '{"userName":"crashhostarray","cpuWeight":10000}' | userdbctl -F -
<stdin>:1:42: JSON field 'cpuWeight' is not in valid range 1…10000.
This commit is contained in:
@@ -554,11 +554,11 @@ static int json_dispatch_weight(const char *name, sd_json_variant *variant, sd_j
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
|
||||
|
||||
k = sd_json_variant_unsigned(variant);
|
||||
if (k <= CGROUP_WEIGHT_MIN || k >= CGROUP_WEIGHT_MAX)
|
||||
if (k < CGROUP_WEIGHT_MIN || k > CGROUP_WEIGHT_MAX)
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE),
|
||||
"JSON field '%s' is not in valid range %" PRIu64 "%s%" PRIu64 ".",
|
||||
strna(name), (uint64_t) CGROUP_WEIGHT_MIN,
|
||||
glyph(GLYPH_ELLIPSIS), (uint64_t) CGROUP_WEIGHT_MAX);
|
||||
strna(name), CGROUP_WEIGHT_MIN,
|
||||
glyph(GLYPH_ELLIPSIS), CGROUP_WEIGHT_MAX);
|
||||
|
||||
*weight = k;
|
||||
return 0;
|
||||
|
||||
@@ -81,3 +81,7 @@ userdbctl group "$DISK_GID" | grep -F 'io.systemd.NameServiceSwitch' >/dev/null
|
||||
(! busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LookupDynamicUserByName "s" disk)
|
||||
(! busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LookupDynamicUserByUID "u" "$DISK_GID")
|
||||
systemctl stop "$UNIT"
|
||||
|
||||
# Probe specific user records
|
||||
echo '{"userName":"weightmin","cpuWeight":1,"ioWeight":1}' | userdbctl -F -
|
||||
echo '{"userName":"weightmax","cpuWeight":10000,"ioWeight":10000}' | userdbctl -F -
|
||||
|
||||
Reference in New Issue
Block a user