202 lines
8.1 KiB
Diff
202 lines
8.1 KiB
Diff
From 5038dc90efcd92e3fbbae06a7d459c8f5d549915 Mon Sep 17 00:00:00 2001
|
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Date: Thu, 19 Oct 2017 22:40:04 +0900
|
|
Subject: [PATCH] core: fix D-Bus API
|
|
|
|
This fixes bugs introduced by cffaed83e87bde81378b2be74192193850d0e03a.
|
|
|
|
Closes #7129.
|
|
|
|
(cherry picked from commit 3f856a2813359ad8203ccad388e54ff41a9ecaf1)
|
|
---
|
|
src/core/dbus-execute.c | 8 ++---
|
|
src/shared/bus-unit-util.c | 79 ++++++++++++++++++++++++++--------------------
|
|
2 files changed, 49 insertions(+), 38 deletions(-)
|
|
|
|
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
|
|
index e0aa9fdd82..26c6e039b8 100644
|
|
--- a/src/core/dbus-execute.c
|
|
+++ b/src/core/dbus-execute.c
|
|
@@ -1189,7 +1189,7 @@ int bus_exec_context_set_transient_property(
|
|
|
|
} else if (streq(name, "SystemCallFilter")) {
|
|
int whitelist;
|
|
- _cleanup_strv_free_ char **l;
|
|
+ _cleanup_strv_free_ char **l = NULL;
|
|
|
|
r = sd_bus_message_enter_container(message, 'r', "bas");
|
|
if (r < 0)
|
|
@@ -1238,7 +1238,7 @@ int bus_exec_context_set_transient_property(
|
|
if (id == __NR_SCMP_ERROR)
|
|
return -EINVAL;
|
|
|
|
- r = set_put(c->address_families, INT_TO_PTR(id + 1));
|
|
+ r = set_put(c->syscall_filter, INT_TO_PTR(id + 1));
|
|
if (r < 0)
|
|
return r;
|
|
}
|
|
@@ -1250,7 +1250,7 @@ int bus_exec_context_set_transient_property(
|
|
if (id == __NR_SCMP_ERROR)
|
|
return -EINVAL;
|
|
|
|
- r = set_put(c->address_families, INT_TO_PTR(id + 1));
|
|
+ r = set_put(c->syscall_filter, INT_TO_PTR(id + 1));
|
|
if (r < 0)
|
|
return r;
|
|
}
|
|
@@ -1330,7 +1330,7 @@ int bus_exec_context_set_transient_property(
|
|
|
|
} else if (streq(name, "RestrictAddressFamilies")) {
|
|
int whitelist;
|
|
- _cleanup_strv_free_ char **l;
|
|
+ _cleanup_strv_free_ char **l = NULL;
|
|
|
|
r = sd_bus_message_enter_container(message, 'r', "bas");
|
|
if (r < 0)
|
|
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
|
|
index 6e2022587a..0b8260193a 100644
|
|
--- a/src/shared/bus-unit-util.c
|
|
+++ b/src/shared/bus-unit-util.c
|
|
@@ -602,12 +602,9 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|
|
|
} else if (streq(field, "SystemCallFilter")) {
|
|
int whitelist;
|
|
+ _cleanup_strv_free_ char **l = NULL;
|
|
const char *p;
|
|
|
|
- r = sd_bus_message_open_container(m, 'v', "bas");
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
p = eq;
|
|
if (*p == '~') {
|
|
whitelist = 0;
|
|
@@ -615,18 +612,10 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|
} else
|
|
whitelist = 1;
|
|
|
|
- r = sd_bus_message_append_basic(m, 'b', &whitelist);
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
- r = sd_bus_message_open_container(m, 'a', "s");
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
if (whitelist != 0) {
|
|
- r = sd_bus_message_append_basic(m, 's', "@default");
|
|
+ r = strv_extend(&l, "@default");
|
|
if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
+ return log_oom();
|
|
}
|
|
|
|
for (;;) {
|
|
@@ -638,16 +627,34 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|
if (r == 0)
|
|
break;
|
|
|
|
- r = sd_bus_message_append_basic(m, 's', word);
|
|
+ r = strv_extend(&l, word);
|
|
if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
+ return log_oom();
|
|
}
|
|
|
|
+ r = sd_bus_message_open_container(m, 'v', "(bas)");
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_open_container(m, 'r', "bas");
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_append_basic(m, 'b', &whitelist);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_append_strv(m, l);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
r = sd_bus_message_close_container(m);
|
|
if (r < 0)
|
|
return bus_log_create_error(r);
|
|
|
|
r = sd_bus_message_close_container(m);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
|
|
} else if (streq(field, "SystemCallArchitectures")) {
|
|
const char *p;
|
|
@@ -691,27 +698,15 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|
|
|
} else if (streq(field, "RestrictAddressFamilies")) {
|
|
int whitelist;
|
|
- const char *p;
|
|
+ _cleanup_strv_free_ char **l = NULL;
|
|
+ const char *p = eq;
|
|
|
|
- r = sd_bus_message_open_container(m, 'v', "bas");
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
- p = eq;
|
|
if (*p == '~') {
|
|
whitelist = 0;
|
|
p++;
|
|
} else
|
|
whitelist = 1;
|
|
|
|
- r = sd_bus_message_append_basic(m, 'b', &whitelist);
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
- r = sd_bus_message_open_container(m, 'a', "s");
|
|
- if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
-
|
|
for (;;) {
|
|
_cleanup_free_ char *word = NULL;
|
|
|
|
@@ -721,19 +716,35 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|
if (r == 0)
|
|
break;
|
|
|
|
- r = sd_bus_message_append_basic(m, 's', word);
|
|
+ r = strv_extend(&l, word);
|
|
if (r < 0)
|
|
- return bus_log_create_error(r);
|
|
+ return log_oom();
|
|
}
|
|
|
|
- r = sd_bus_message_close_container(m);
|
|
+ r = sd_bus_message_open_container(m, 'v', "(bas)");
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_open_container(m, 'r', "bas");
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_append_basic(m, 'b', &whitelist);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
+
|
|
+ r = sd_bus_message_append_strv(m, l);
|
|
if (r < 0)
|
|
return bus_log_create_error(r);
|
|
|
|
r = sd_bus_message_close_container(m);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
|
|
+ r = sd_bus_message_close_container(m);
|
|
+ if (r < 0)
|
|
+ return bus_log_create_error(r);
|
|
#endif
|
|
-
|
|
} else if (streq(field, "FileDescriptorStoreMax")) {
|
|
unsigned u;
|
|
|