Skip to content

Commit

Permalink
Ensure kdbus isn't used (systemd#3501)
Browse files Browse the repository at this point in the history
Delete the dbus1 generator and some critical wiring. This prevents
kdbus from being loaded or detected. As such, it will never be used,
even if the user still has a useful kdbus module loaded on their system.

Sort of fixes systemd#3480. Not really, but it's better than the current state.
  • Loading branch information
falconindy authored and keszybz committed Jun 18, 2016
1 parent 6564ab0 commit 222953e
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 470 deletions.
20 changes: 0 additions & 20 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2902,29 +2902,9 @@ systemd_gpt_auto_generator_CFLAGS = \
endif

# ------------------------------------------------------------------------------
systemgenerator_PROGRAMS += \
systemd-dbus1-generator

systemd_dbus1_generator_SOURCES = \
src/dbus1-generator/dbus1-generator.c

systemd_dbus1_generator_LDADD = \
libshared.la

dbus1-generator-install-hook:
$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(usergeneratordir)
$(AM_V_RM)rm -f $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator
$(AM_V_LN)$(LN_S) --relative -f $(DESTDIR)$(systemgeneratordir)/systemd-dbus1-generator $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator

dbus1-generator-uninstall-hook:
rm -f $(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator

dist_xinitrc_SCRIPTS = \
xorg/50-systemd-user.sh

INSTALL_EXEC_HOOKS += dbus1-generator-install-hook
UNINSTALL_EXEC_HOOKS += dbus1-generator-uninstall-hook

# ------------------------------------------------------------------------------
systemd_sysv_generator_SOURCES = \
src/sysv-generator/sysv-generator.c
Expand Down
12 changes: 6 additions & 6 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ fi
cd $oldpwd

if [ "x$1" = "xc" ]; then
$topdir/configure CFLAGS='-g -O0 -ftrapv' --enable-kdbus $args
$topdir/configure CFLAGS='-g -O0 -ftrapv' $args
make clean
elif [ "x$1" = "xg" ]; then
$topdir/configure CFLAGS='-g -Og -ftrapv' --enable-kdbus $args
$topdir/configure CFLAGS='-g -Og -ftrapv' $args
make clean
elif [ "x$1" = "xa" ]; then
$topdir/configure CFLAGS='-g -O0 -Wsuggest-attribute=pure -Wsuggest-attribute=const -ftrapv' --enable-kdbus $args
$topdir/configure CFLAGS='-g -O0 -Wsuggest-attribute=pure -Wsuggest-attribute=const -ftrapv' $args
make clean
elif [ "x$1" = "xl" ]; then
$topdir/configure CC=clang CFLAGS='-g -O0 -ftrapv' --enable-kdbus $args
$topdir/configure CC=clang CFLAGS='-g -O0 -ftrapv' $args
make clean
elif [ "x$1" = "xs" ]; then
scan-build $topdir/configure CFLAGS='-std=gnu99 -g -O0 -ftrapv' --enable-kdbus $args
scan-build $topdir/configure CFLAGS='-std=gnu99 -g -O0 -ftrapv' $args
scan-build make
else
echo
echo "----------------------------------------------------------------"
echo "Initialized build system. For a common configuration please run:"
echo "----------------------------------------------------------------"
echo
echo "$topdir/configure CFLAGS='-g -O0 -ftrapv' --enable-kdbus $args"
echo "$topdir/configure CFLAGS='-g -O0 -ftrapv' $args"
echo
fi
10 changes: 0 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1279,16 +1279,6 @@ AC_ARG_WITH(tpm-pcrindex,

AC_DEFINE_UNQUOTED(SD_TPM_PCR, [$SD_TPM_PCR], [TPM PCR register number to use])

# ------------------------------------------------------------------------------
have_kdbus=no
AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--disable-kdbus], [do not connect to kdbus by default]))
if test "x$enable_kdbus" != "xno"; then
AC_DEFINE(ENABLE_KDBUS, 1, [Define if kdbus is to be connected to by default])
have_kdbus=yes
M4_DEFINES="$M4_DEFINES -DENABLE_KDBUS"
fi
AM_CONDITIONAL(ENABLE_KDBUS, [test "$have_kdbus" = "yes"])

# ------------------------------------------------------------------------------
AC_ARG_WITH(rc-local-script-path-start,
AS_HELP_STRING([--with-rc-local-script-path-start=PATH],
Expand Down
7 changes: 1 addition & 6 deletions src/core/busname.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,12 +998,7 @@ static int busname_get_timeout(Unit *u, usec_t *timeout) {
}

static bool busname_supported(void) {
static int supported = -1;

if (supported < 0)
supported = is_kdbus_available();

return supported;
return false;
}

static int busname_control_pid(Unit *u) {
Expand Down
3 changes: 0 additions & 3 deletions src/core/kmod-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ int kmod_setup(void) {
/* this should never be a module */
{ "unix", "/proc/net/unix", true, true, NULL },

/* IPC is needed before we bring up any other services */
{ "kdbus", "/sys/fs/kdbus", false, false, is_kdbus_wanted },

#ifdef HAVE_LIBIPTC
/* netfilter is needed by networkd, nspawn among others, and cannot be autoloaded */
{ "ip_tables", "/proc/net/ip_tables_names", false, false, NULL },
Expand Down
23 changes: 0 additions & 23 deletions src/core/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,28 +814,6 @@ static int manager_setup_cgroups_agent(Manager *m) {
return 0;
}

static int manager_setup_kdbus(Manager *m) {
_cleanup_free_ char *p = NULL;

assert(m);

if (m->test_run || m->kdbus_fd >= 0)
return 0;
if (!is_kdbus_available())
return -ESOCKTNOSUPPORT;

m->kdbus_fd = bus_kernel_create_bus(
MANAGER_IS_SYSTEM(m) ? "system" : "user",
MANAGER_IS_SYSTEM(m), &p);

if (m->kdbus_fd < 0)
return log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m");

log_debug("Successfully set up kdbus on %s", p);

return 0;
}

static int manager_connect_bus(Manager *m, bool reexecuting) {
bool try_bus_connect;

Expand Down Expand Up @@ -1244,7 +1222,6 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {

/* We might have deserialized the kdbus control fd, but if we
* didn't, then let's create the bus now. */
manager_setup_kdbus(m);
manager_connect_bus(m, !!serialization);
bus_track_coldplug(m, &m->subscribed, &m->deserialized_subscribed);

Expand Down
2 changes: 0 additions & 2 deletions src/core/mount-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ static const MountPoint mount_table[] = {
{ "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
is_efi_boot, MNT_NONE },
#endif
{ "kdbusfs", "/sys/fs/kdbus", "kdbusfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
is_kdbus_wanted, MNT_IN_CONTAINER },
};

/* These are API file systems that might be mounted by other software,
Expand Down
17 changes: 3 additions & 14 deletions src/core/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,9 @@ static int service_setup_bus_name(Service *s) {
if (!s->bus_name)
return 0;

if (is_kdbus_available()) {
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 log_unit_error_errno(UNIT(s), r, "Failed to add dependency to .busname unit: %m");

} else {
/* If kdbus is not available, we know the dbus socket is required, hence pull it in, and require it */
r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, NULL, true);
if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m");
}
r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, NULL, true);
if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m");

/* Regardless if kdbus is used or not, we always want to be ordered against dbus.socket if both are in the transaction. */
r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_DBUS_SOCKET, NULL, true);
Expand Down
Loading

0 comments on commit 222953e

Please sign in to comment.