|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From e44da745d19b9e02e67e32ea82c3bad86175120c Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Daniel Mack <zonque@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Fri, 22 Aug 2014 19:02:03 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] service: hook up custom endpoint logic
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
If BusPolicy= was passed, the parser function will have created
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
an ExecContext->bus_endpoint object, along with policy information.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
In that case, create a kdbus endpoint, and pass its path name to the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
namespace logic, to it will be mounted over the actual 'bus' node.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
At endpoint creation time, no policy is updloaded. That is done after
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
fork(), through a separate call. This is necessary because we don't
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
know the real uid of the process earlier than that.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/execute.c | 24 +++++++++++++++++++++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/execute.h | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/service.c | 39 ++++++++++++++++++++++++++++++++++++++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/service.h | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
4 files changed, 63 insertions(+), 4 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/execute.c b/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 96cabe6d99..2b16b36c19 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -83,6 +83,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "af-list.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "mkdir.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "apparmor-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#include "bus-kernel.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#ifdef HAVE_SECCOMP
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "seccomp-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1236,7 +1237,7 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_strv_free_ char **our_env = NULL, **pam_env = NULL, **final_env = NULL, **final_argv = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *username = NULL, *home = NULL, *shell = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned n_dont_close = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- int dont_close[n_fds + 3];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int dont_close[n_fds + 4];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uid_t uid = (uid_t) -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
gid_t gid = (gid_t) -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int i, err;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1279,6 +1280,8 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
memcpy(dont_close + n_dont_close, fds, sizeof(int) * n_fds);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
n_dont_close += n_fds;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (params->bus_endpoint_fd >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ dont_close[n_dont_close++] = params->bus_endpoint_fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (runtime) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (runtime->netns_storage_socket[0] >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
dont_close[n_dont_close++] = runtime->netns_storage_socket[0];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1428,6 +1431,18 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#ifdef ENABLE_KDBUS
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (params->bus_endpoint_fd >= 0 && context->bus_endpoint) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uid_t ep_uid = (uid == (uid_t) -1) ? 0 : uid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ err = bus_kernel_set_endpoint_policy(params->bus_endpoint_fd, ep_uid, context->bus_endpoint);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (err < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ *error = EXIT_BUS_ENDPOINT;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return err;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#endif
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#ifdef HAVE_PAM
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (params->cgroup_path && context->user && context->pam_name) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
err = cg_set_task_access(SYSTEMD_CGROUP_CONTROLLER, params->cgroup_path, 0644, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1498,6 +1513,7 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
!strv_isempty(context->inaccessible_dirs) ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->mount_flags != 0 ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
(context->private_tmp && runtime && (runtime->tmp_dir || runtime->var_tmp_dir)) ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ params->bus_endpoint_path ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->private_devices ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->protect_system != PROTECT_SYSTEM_NO ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->protect_home != PROTECT_HOME_NO) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1523,7 +1539,7 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->inaccessible_dirs,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
tmp,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
var,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- NULL,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ params->bus_endpoint_path,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->private_devices,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->protect_home,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context->protect_system,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1564,7 +1580,9 @@ static int exec_child(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* We repeat the fd closing here, to make sure that
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* nothing is leaked from the PAM modules. Note that
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* we are more aggressive this time since socket_fd
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * and the netns fds we don#t need anymore. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * and the netns fds we don't need anymore. The custom
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * endpoint fd was needed to upload the policy and can
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * now be closed as well. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
err = close_all_fds(fds, n_fds);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (err >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
err = shift_fds(fds, n_fds);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/execute.h b/src/core/execute.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index e3cebfd72c..9c1f249cd4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/execute.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/execute.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -210,6 +210,8 @@ struct ExecParameters {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *unit_id;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
usec_t watchdog_usec;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int *idle_pipe;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ char *bus_endpoint_path;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int bus_endpoint_fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int exec_spawn(ExecCommand *command,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/service.c b/src/core/service.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f3775f24c4..3f6595c5c8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/service.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/service.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -45,6 +45,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "fileio.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "bus-error.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "bus-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#include "bus-kernel.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
[SERVICE_DEAD] = UNIT_INACTIVE,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -102,6 +103,7 @@ static void service_init(Unit *u) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->restart_usec = u->manager->default_restart_usec;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->type = _SERVICE_TYPE_INVALID;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->socket_fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->bus_endpoint_fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->guess_main_pid = true;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
RATELIMIT_INIT(s->start_limit, u->manager->default_start_limit_interval, u->manager->default_start_limit_burst);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -273,6 +275,7 @@ static void service_done(Unit *u) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->bus_name = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->bus_endpoint_fd = safe_close(s->bus_endpoint_fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
service_close_socket_fd(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
service_connection_unref(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -889,6 +892,7 @@ static int service_spawn(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int *fds = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_free_ int *fdsbuf = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned n_fds = 0, n_env = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ _cleanup_free_ char *bus_endpoint_path = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_strv_free_ char
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
**argv = NULL, **final_env = NULL, **our_env = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *path;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -896,6 +900,7 @@ static int service_spawn(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
.apply_permissions = apply_permissions,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
.apply_chroot = apply_chroot,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
.apply_tty_stdin = apply_tty_stdin,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .bus_endpoint_fd = -1,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -972,6 +977,20 @@ static int service_spawn(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
path = UNIT(s)->cgroup_path;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#ifdef ENABLE_KDBUS
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (s->exec_context.bus_endpoint) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = bus_kernel_create_endpoint(UNIT(s)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ UNIT(s)->id, &bus_endpoint_path);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* Pass the fd to the exec_params so that the child process can upload the policy.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * Keep a reference to the fd in the service, so the endpoint is kept alive as long
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * as the service is running. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ exec_params.bus_endpoint_fd = s->bus_endpoint_fd = r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#endif
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.argv = argv;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.fds = fds;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.n_fds = n_fds;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -982,6 +1001,7 @@ static int service_spawn(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.runtime_prefix = manager_get_runtime_prefix(UNIT(s)->manager);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.unit_id = UNIT(s)->id;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.watchdog_usec = s->watchdog_usec;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ exec_params.bus_endpoint_path = bus_endpoint_path;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (s->type == SERVICE_IDLE)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exec_params.idle_pipe = UNIT(s)->manager->idle_pipe;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1770,6 +1790,15 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unit_serialize_item_format(u, f, "socket-fd", "%i", copy);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (s->bus_endpoint_fd >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int copy;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if ((copy = fdset_put_dup(fds, s->bus_endpoint_fd)) < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return copy;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ unit_serialize_item_format(u, f, "endpoint-fd", "%i", copy);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (s->main_exec_status.pid > 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unit_serialize_item_format(u, f, "main-exec-status-pid", PID_FMT,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->main_exec_status.pid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1879,10 +1908,18 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug_unit(u->id, "Failed to parse socket-fd value %s", value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
asynchronous_close(s->socket_fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
s->socket_fd = fdset_remove(fds, fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ } else if (streq(key, "endpoint-fd")) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_debug_unit(u->id, "Failed to parse endpoint-fd value %s", value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ safe_close(s->bus_endpoint_fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->bus_endpoint_fd = fdset_remove(fds, fd);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else if (streq(key, "main-exec-status-pid")) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
pid_t pid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/service.h b/src/core/service.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 5bcfd14339..ad0b3b381e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/service.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/service.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -162,6 +162,8 @@ struct Service {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
pid_t main_pid, control_pid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int socket_fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int bus_endpoint_fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool permissions_start_only;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool root_directory_start_only;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool remain_after_exit;
|