Merge pull request #263 from kaysievers/wip
turn kdbus support into a runtime option
This commit is contained in:
+1
-7
@@ -63,13 +63,7 @@
|
||||
|
||||
#define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
|
||||
#define KERNEL_SYSTEM_BUS_ADDRESS "kernel:path=/sys/fs/kdbus/0-system/bus"
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
# define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS
|
||||
#else
|
||||
# define DEFAULT_SYSTEM_BUS_ADDRESS UNIX_SYSTEM_BUS_ADDRESS
|
||||
#endif
|
||||
|
||||
#define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS
|
||||
#define UNIX_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
|
||||
#define KERNEL_USER_BUS_ADDRESS_FMT "kernel:path=/sys/fs/kdbus/"UID_FMT"-user/bus"
|
||||
|
||||
|
||||
@@ -239,11 +239,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (!e)
|
||||
return log_oom();
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
a = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e, NULL);
|
||||
#else
|
||||
a = strjoin("x-machine-unix:machine=", e, NULL);
|
||||
#endif
|
||||
if (!a)
|
||||
return log_oom();
|
||||
|
||||
|
||||
@@ -110,11 +110,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (!e)
|
||||
return log_oom();
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
a = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e, NULL);
|
||||
#else
|
||||
a = strjoin("x-machine-unix:machine=", e, NULL);
|
||||
#endif
|
||||
if (!a)
|
||||
return log_oom();
|
||||
|
||||
|
||||
@@ -1514,7 +1514,6 @@ static int exec_child(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
if (params->bus_endpoint_fd >= 0 && context->bus_endpoint) {
|
||||
uid_t ep_uid = (uid == UID_INVALID) ? 0 : uid;
|
||||
|
||||
@@ -1524,7 +1523,6 @@ static int exec_child(
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If delegation is enabled we'll pass ownership of the cgroup
|
||||
* (but only in systemd's own controller hierarchy!) to the
|
||||
|
||||
@@ -66,10 +66,8 @@ int kmod_setup(void) {
|
||||
/* this should never be a module */
|
||||
{ "unix", "/proc/net/unix", true, true, NULL },
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
/* IPC is needed before we bring up any other services */
|
||||
{ "kdbus", "/sys/fs/kdbus", false, false, is_kdbus_wanted },
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBIPTC
|
||||
/* netfilter is needed by networkd, nspawn among others, and cannot be autoloaded */
|
||||
|
||||
@@ -229,9 +229,7 @@ Service.BusName, config_parse_bus_name, 0,
|
||||
Service.FileDescriptorStoreMax, config_parse_unsigned, 0, offsetof(Service, n_fd_store_max)
|
||||
Service.NotifyAccess, config_parse_notify_access, 0, offsetof(Service, notify_access)
|
||||
Service.Sockets, config_parse_service_sockets, 0, 0
|
||||
m4_ifdef(`ENABLE_KDBUS',
|
||||
`Service.BusPolicy, config_parse_bus_endpoint_policy, 0, offsetof(Service, exec_context)',
|
||||
`Service.BusPolicy, config_parse_warn_compat, DISABLED_EXPERIMENTAL, 0')
|
||||
Service.BusPolicy, config_parse_bus_endpoint_policy, 0, offsetof(Service, exec_context)
|
||||
EXEC_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
|
||||
CGROUP_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
|
||||
KILL_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
|
||||
|
||||
@@ -731,7 +731,6 @@ static int manager_setup_notify(Manager *m) {
|
||||
}
|
||||
|
||||
static int manager_setup_kdbus(Manager *m) {
|
||||
#ifdef ENABLE_KDBUS
|
||||
_cleanup_free_ char *p = NULL;
|
||||
|
||||
assert(m);
|
||||
@@ -749,7 +748,6 @@ static int manager_setup_kdbus(Manager *m) {
|
||||
return log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m");
|
||||
|
||||
log_debug("Successfully set up kdbus on %s", p);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,10 +104,8 @@ static const MountPoint mount_table[] = {
|
||||
{ "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||
is_efi_boot, MNT_NONE },
|
||||
#endif
|
||||
#ifdef ENABLE_KDBUS
|
||||
{ "kdbusfs", "/sys/fs/kdbus", "kdbusfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||
NULL, MNT_IN_CONTAINER },
|
||||
#endif
|
||||
};
|
||||
|
||||
/* These are API file systems that might be mounted by other software,
|
||||
|
||||
@@ -568,14 +568,12 @@ static int service_add_extras(Service *s) {
|
||||
s->notify_access = NOTIFY_MAIN;
|
||||
|
||||
if (s->bus_name) {
|
||||
#ifdef ENABLE_KDBUS
|
||||
const char *n;
|
||||
|
||||
n = strjoina(s->bus_name, ".busname");
|
||||
r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, n, NULL, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
#endif
|
||||
|
||||
r = unit_watch_bus_name(UNIT(s), s->bus_name);
|
||||
if (r < 0)
|
||||
@@ -1180,7 +1178,6 @@ static int service_spawn(
|
||||
} else
|
||||
path = UNIT(s)->cgroup_path;
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
if (s->exec_context.bus_endpoint) {
|
||||
r = bus_kernel_create_endpoint(UNIT(s)->manager->running_as == MANAGER_SYSTEM ? "system" : "user",
|
||||
UNIT(s)->id, &bus_endpoint_path);
|
||||
@@ -1192,7 +1189,6 @@ static int service_spawn(
|
||||
* as the service is running. */
|
||||
exec_params.bus_endpoint_fd = s->bus_endpoint_fd = r;
|
||||
}
|
||||
#endif
|
||||
|
||||
exec_params.argv = argv;
|
||||
exec_params.fds = fds;
|
||||
|
||||
@@ -1239,18 +1239,9 @@ int bus_set_address_user(sd_bus *b) {
|
||||
if (!ee)
|
||||
return -ENOMEM;
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, getuid(), ee);
|
||||
#else
|
||||
(void) asprintf(&b->address, UNIX_USER_BUS_ADDRESS_FMT, ee);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ENABLE_KDBUS
|
||||
} else
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
|
||||
#else
|
||||
return -ECONNREFUSED;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!b->address)
|
||||
return -ENOMEM;
|
||||
@@ -1372,11 +1363,7 @@ int bus_set_address_system_machine(sd_bus *b, const char *machine) {
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
b->address = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e, NULL);
|
||||
#else
|
||||
b->address = strjoin("x-machine-unix:machine=", e, NULL);
|
||||
#endif
|
||||
if (!b->address)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -177,7 +177,6 @@ static int export_legacy_dbus_address(
|
||||
uid_t uid,
|
||||
const char *runtime) {
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
@@ -195,7 +194,7 @@ static int export_legacy_dbus_address(
|
||||
pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
return PAM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -509,11 +509,7 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
# define ADDRESS_FMT "x-machine-kernel:pid=%1$" PID_PRI ";x-machine-unix:pid=%1$" PID_PRI
|
||||
#else
|
||||
# define ADDRESS_FMT "x-machine-unix:pid=%1$" PID_PRI
|
||||
#endif
|
||||
if (asprintf(&address, ADDRESS_FMT, m->leader) < 0)
|
||||
return log_oom();
|
||||
|
||||
|
||||
+13
-10
@@ -545,7 +545,6 @@ int bus_open_system_systemd(sd_bus **_bus) {
|
||||
* directly to the system instance, instead of going via the
|
||||
* bus */
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
r = sd_bus_new(&bus);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -564,7 +563,6 @@ int bus_open_system_systemd(sd_bus **_bus) {
|
||||
}
|
||||
|
||||
bus = sd_bus_unref(bus);
|
||||
#endif
|
||||
|
||||
r = sd_bus_new(&bus);
|
||||
if (r < 0)
|
||||
@@ -598,7 +596,6 @@ int bus_open_user_systemd(sd_bus **_bus) {
|
||||
|
||||
assert(_bus);
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
r = sd_bus_new(&bus);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -616,7 +613,6 @@ int bus_open_user_systemd(sd_bus **_bus) {
|
||||
}
|
||||
|
||||
bus = sd_bus_unref(bus);
|
||||
#endif
|
||||
|
||||
e = secure_getenv("XDG_RUNTIME_DIR");
|
||||
if (!e)
|
||||
@@ -2034,15 +2030,22 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
|
||||
|
||||
bool is_kdbus_wanted(void) {
|
||||
_cleanup_free_ char *value = NULL;
|
||||
#ifdef ENABLE_KDBUS
|
||||
const bool configured = true;
|
||||
#else
|
||||
const bool configured = false;
|
||||
#endif
|
||||
|
||||
int r;
|
||||
|
||||
if (get_proc_cmdline_key("kdbus", NULL) <= 0) {
|
||||
r = get_proc_cmdline_key("kdbus=", &value);
|
||||
if (r <= 0 || parse_boolean(value) != 1)
|
||||
return false;
|
||||
}
|
||||
if (get_proc_cmdline_key("kdbus", NULL) > 0)
|
||||
return true;
|
||||
|
||||
return true;
|
||||
r = get_proc_cmdline_key("kdbus=", &value);
|
||||
if (r <= 0)
|
||||
return configured;
|
||||
|
||||
return parse_boolean(value) == 1;
|
||||
}
|
||||
|
||||
bool is_kdbus_available(void) {
|
||||
|
||||
Reference in New Issue
Block a user