File 0012-core-cgroup-accepts-MemorySwapMax-0-8366.patch of Package systemd-mini.17049

From f701e657ed04d9309134f5b0c2c55f7fe5591a59 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 9 Jul 2020 19:28:12 +0200
Subject: [PATCH 12/15] core/cgroup: accepts MemorySwapMax=0 (#8366)

Also, this moves two macros from dbus-util.h to dbus-cgroup.c,
as they are only used in dbus-cgroup.c.

Fixes #8363.

(cherry picked from commit 906bdbf5e79870f6997fc0925348f9412f3c5f3e)

[mkoutny: simplify range condition, we don't have 681ae88e06 ("dbus-cgroup: simplify bus_cgroup_set_property()") v237~157^2]
[fbui: fixes bsc#1154935]
---
 src/core/dbus-cgroup.c   | 4 ++--
 src/core/load-fragment.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 6d05c337a1..a90887c8a0 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -939,7 +939,7 @@ int bus_cgroup_set_property(
                 r = sd_bus_message_read(message, "t", &v);
                 if (r < 0)
                         return r;
-                if (v <= 0)
+                if (v <= 0 && !streq(name, "MemorySwapMax"))
                         return sd_bus_error_set_errnof(error, EINVAL, "%s= is too small", name);
 
                 if (mode != UNIT_CHECK) {
@@ -971,7 +971,7 @@ int bus_cgroup_set_property(
                         return r;
 
                 v = physical_memory_scale(raw, UINT32_MAX);
-                if (v <= 0 || v == UINT64_MAX)
+                if ((v <= 0 && !streq(name, "MemorySwapMaxScale")) || v == UINT64_MAX)
                         return sd_bus_error_set_errnof(error, EINVAL, "%s= is out of range", name);
 
                 if (mode != UNIT_CHECK) {
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index b115027222..1844c5c3d7 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3055,7 +3055,8 @@ int config_parse_memory_limit(
                 } else
                         bytes = physical_memory_scale(r, 100U);
 
-                if (bytes <= 0 || bytes >= UINT64_MAX) {
+                if (bytes >= UINT64_MAX ||
+                    (bytes <= 0 && !streq(lvalue, "MemorySwapMax"))) {
                         log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range. Ignoring.", rvalue);
                         return 0;
                 }
-- 
2.26.2

openSUSE Build Service is sponsored by