File 0013-cgroup-Support-0-value-for-memory-protection-directi.patch of Package systemd-mini.18248

From a800431e4add2685a7c3855fea290eff7468b58b Mon Sep 17 00:00:00 2001
From: Chris Down <chris@chrisdown.name>
Date: Thu, 9 Jul 2020 19:28:13 +0200
Subject: [PATCH 13/15] cgroup: Support 0-value for memory protection
 directives

These make sense to be explicitly set at 0 (which has a different effect
than the default, since it can affect processing of `DefaultMemoryXXX`).

Without this, it's not easily possible to relinquish memory protection
for a subtree, which is not great.

(cherry picked from commit 22bf131be278b95a4a204514d37a4344cf6365c6)

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

diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index a90887c8a0..5e35d74f0d 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 && !streq(name, "MemorySwapMax"))
+                if (v <= 0 && !STR_IN_SET(name, "MemoryLow", "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 && !streq(name, "MemorySwapMaxScale")) || v == UINT64_MAX)
+                if ((v <= 0 && !STR_IN_SET(name, "MemoryLowScale", "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 1844c5c3d7..213404ee31 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3056,7 +3056,7 @@ int config_parse_memory_limit(
                         bytes = physical_memory_scale(r, 100U);
 
                 if (bytes >= UINT64_MAX ||
-                    (bytes <= 0 && !streq(lvalue, "MemorySwapMax"))) {
+                    (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow"))) {
                         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