|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
From 19da3fec80d3e30191be11f6dc7305f6c82e5254 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
Date: Wed, 18 Apr 2018 18:48:55 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
Subject: [PATCH] Allow Delegate= to be set on transient units
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
src/core/dbus-cgroup.c | 13 +++++++------
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
1 file changed, 7 insertions(+), 6 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
index d77f96fdb3..489112087f 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
--- a/src/core/dbus-cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+++ b/src/core/dbus-cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
@@ -32,6 +32,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
#include "fd-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
#include "fileio.h"
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
#include "path-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+#include "unit.h"
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
@@ -351,13 +352,13 @@ static int bus_cgroup_set_transient_property(
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
if (streq(name, "Delegate")) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
int b;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
- if (!UNIT_VTABLE(u)->can_delegate)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type");
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
r = sd_bus_message_read(message, "b", &b);
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+ if (!UNIT_VTABLE(u)->can_delegate && b)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+ log_unit_notice(u, "Delegate=yes set, but has no effect for unit type");
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
c->delegate = b;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
c->delegate_controllers = b ? _CGROUP_MASK_ALL : 0;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
@@ -370,9 +371,6 @@ static int bus_cgroup_set_transient_property(
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
} else if (streq(name, "DelegateControllers")) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
CGroupMask mask = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
- if (!UNIT_VTABLE(u)->can_delegate)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type");
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
r = sd_bus_message_enter_container(message, 'a', "s");
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
@@ -414,6 +412,9 @@ static int bus_cgroup_set_transient_property(
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t));
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+ if (!UNIT_VTABLE(u)->can_delegate && c->delegate)
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+ log_unit_notice(u, "Delegate=yes set, but has no effect for unit type");
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
return 1;
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb3fb8 |
|