From 82db02756c161c91eeaaf5a1b4f20837ec57bbde Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 31 Mar 2021 21:46:02 +0200 Subject: [PATCH] Make D-Bus and udisks2 available early (#1291) * Disable systemd-logind support for udisks2 Currently udisks2 uses systemd-logind to prevent the system from rebooting or similar operations while udisks operations are ongoing. Unfortunately this stops us from using udisks2 during early boot since systemd-logind is not ready at this point. Make the dependency configureable so we can opt-out of using systemd-logind. * Make dbus.service/socket and udisks2.service/socket available early Disable default dependencies. This avoids those services to be ordered after sysinit.target, and makes them available before local-fs.target is reached. All mounts like mnt-data.mount are ordered before local-fs.target, so breaking this dependency allows to use D-Bus before mounting local file systems. This seems fine when using the system bus directly from /run (instead of /var/run, which is anyway a symlink to /run normally). It seems that udisks misses /var/lib/udisks2 but it seems not to be required for the features used so far. --- ...-explicitly-disable-libsystemd-login.patch | 51 +++++++++++++++++++ buildroot-external/package/udisks2/udisks2.mk | 2 +- .../systemd/system/dbus.service.d/haos.conf | 2 + .../systemd/system/dbus.socket.d/haos.conf | 2 + .../system/udisks2.service.d/haos.conf | 5 ++ .../systemd/system/udisks2.socket.d/haos.conf | 2 + 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 buildroot-external/package/udisks2/0001-Allow-to-explicitly-disable-libsystemd-login.patch create mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/dbus.service.d/haos.conf create mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/dbus.socket.d/haos.conf create mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.service.d/haos.conf create mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.socket.d/haos.conf diff --git a/buildroot-external/package/udisks2/0001-Allow-to-explicitly-disable-libsystemd-login.patch b/buildroot-external/package/udisks2/0001-Allow-to-explicitly-disable-libsystemd-login.patch new file mode 100644 index 000000000..62df39d00 --- /dev/null +++ b/buildroot-external/package/udisks2/0001-Allow-to-explicitly-disable-libsystemd-login.patch @@ -0,0 +1,51 @@ +From a00ce68f8b08abb925bf22c0c46858958dd93866 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Stefan Agner +Date: Thu, 25 Mar 2021 11:35:12 +0100 +Subject: [PATCH] Allow to explicitly disable libsystemd-login + +Currently libsystemd-login is used to inhibit poweroff, sleep and +reboot. The library makes calls to systemd-logind which in turn needs +quite some services to be present. This can be problematic when using +udisks in early boot stages. +--- + configure.ac | 21 +++++++++++++-------- + 1 file changed, 13 insertions(+), 8 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 53917998..0b3f0c9a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -197,16 +197,21 @@ if test "x$enable_daemon" = "xyes"; then + [AC_DEFINE([UUID_STR_LEN], 37, [compat UUID_STR_LEN define])], + [[#include ]]) + +- PKG_CHECK_MODULES(LIBSYSTEMD_LOGIN, [libsystemd >= 209], [have_libsystemd_login=yes], +- [PKG_CHECK_MODULES(LIBSYSTEMD_LOGIN, [libsystemd-login >= 44 libsystemd-daemon], +- [have_libsystemd_login=yes], +- [have_libsystemd_login=no])]) +- if test "x$have_libsystemd_login" = "xyes"; then +- AC_DEFINE([HAVE_LIBSYSTEMD_LOGIN], 1, [Define to 1 if libsystemd-login is available]) ++ have_libsystemd_login=no ++ AC_ARG_ENABLE(libsystemd-login, AS_HELP_STRING([--disable-libsystemd-login], [disable libsystemd-login support])) ++ if test "x$enable_libsystemd_login" != "xno"; then ++ PKG_CHECK_MODULES(LIBSYSTEMD_LOGIN, [libsystemd >= 209], [have_libsystemd_login=yes], ++ [PKG_CHECK_MODULES(LIBSYSTEMD_LOGIN, [libsystemd-login >= 44 libsystemd-daemon], ++ [have_libsystemd_login=yes], ++ [have_libsystemd_login=no])]) ++ if test "x$have_libsystemd_login" = "xyes"; then ++ AC_DEFINE([HAVE_LIBSYSTEMD_LOGIN], 1, [Define to 1 if libsystemd-login is available]) ++ fi ++ AC_SUBST(LIBSYSTEMD_LOGIN_CFLAGS) ++ AC_SUBST(LIBSYSTEMD_LOGIN_LIBS) + fi ++ AM_CONDITIONAL([HAVE_LIBSYSTEMD_LOGIN], [test "x$have_libsystemd_login" = "xyes"]) + AC_SUBST(HAVE_LIBSYSTEMD_LOGIN) +- AC_SUBST(LIBSYSTEMD_LOGIN_CFLAGS) +- AC_SUBST(LIBSYSTEMD_LOGIN_LIBS) + + PKG_CHECK_MODULES(LIBELOGIND, [libelogind >= 219], + [have_libelogind=yes], +-- +2.30.2 + diff --git a/buildroot-external/package/udisks2/udisks2.mk b/buildroot-external/package/udisks2/udisks2.mk index 40243985b..bfb0b81a5 100644 --- a/buildroot-external/package/udisks2/udisks2.mk +++ b/buildroot-external/package/udisks2/udisks2.mk @@ -25,7 +25,7 @@ UDISKS2_DEPENDENCIES = \ parted \ udev -UDISKS2_CONF_OPTS = --disable-polkit --disable-man +UDISKS2_CONF_OPTS = --disable-polkit --disable-man --disable-libsystemd-login ifeq ($(BR2_PACKAGE_GOBJECT_INTROSPECTION),y) UDISKS2_CONF_OPTS += --enable-introspection diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.service.d/haos.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.service.d/haos.conf new file mode 100644 index 000000000..911bbfa0c --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.service.d/haos.conf @@ -0,0 +1,2 @@ +[Unit] +DefaultDependencies=no diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.socket.d/haos.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.socket.d/haos.conf new file mode 100644 index 000000000..911bbfa0c --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/dbus.socket.d/haos.conf @@ -0,0 +1,2 @@ +[Unit] +DefaultDependencies=no diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.service.d/haos.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.service.d/haos.conf new file mode 100644 index 000000000..fdabc3101 --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.service.d/haos.conf @@ -0,0 +1,5 @@ +[Unit] +DefaultDependencies=no + +[Service] +Environment="DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket" diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.socket.d/haos.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.socket.d/haos.conf new file mode 100644 index 000000000..911bbfa0c --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/udisks2.socket.d/haos.conf @@ -0,0 +1,2 @@ +[Unit] +DefaultDependencies=no