From c18a0fe7f5db85b7d85a3c795246c3bbad02ccaf Mon Sep 17 00:00:00 2001 From: Philip Meulengracht Date: Fri, 30 Aug 2024 10:29:38 +0200 Subject: [PATCH] feat(24.04): add dbus slices (#293) --------- Co-authored-by: Rafid Bin Mostofa Co-authored-by: Cristovao Cordeiro --- slices/dbus-bin.yaml | 20 ++++++++++++++ slices/dbus-daemon.yaml | 31 ++++++++++++++++++++++ slices/dbus-session-bus-common.yaml | 14 ++++++++++ slices/dbus-system-bus-common.yaml | 23 ++++++++++++++++ slices/dbus.yaml | 35 +++++++++++++++++++++++++ slices/libdbus-1-3.yaml | 16 +++++++++++ tests/spread/integration/dbus/task.yaml | 20 ++++++++++++++ tests/spread/integration/dbus/test.sh | 13 +++++++++ 8 files changed, 172 insertions(+) create mode 100644 slices/dbus-bin.yaml create mode 100644 slices/dbus-daemon.yaml create mode 100644 slices/dbus-session-bus-common.yaml create mode 100644 slices/dbus-system-bus-common.yaml create mode 100644 slices/dbus.yaml create mode 100644 slices/libdbus-1-3.yaml create mode 100644 tests/spread/integration/dbus/task.yaml create mode 100755 tests/spread/integration/dbus/test.sh diff --git a/slices/dbus-bin.yaml b/slices/dbus-bin.yaml new file mode 100644 index 000000000..25bdbd3c3 --- /dev/null +++ b/slices/dbus-bin.yaml @@ -0,0 +1,20 @@ +package: dbus-bin + +essential: + - dbus-bin_copyright + +slices: + bins: + essential: + - libc6_libs + - libdbus-1-3_libs + contents: + /usr/bin/dbus-cleanup-sockets: + /usr/bin/dbus-monitor: + /usr/bin/dbus-send: + /usr/bin/dbus-update-activation-environment: + /usr/bin/dbus-uuidgen: + + copyright: + contents: + /usr/share/doc/dbus-bin/copyright: diff --git a/slices/dbus-daemon.yaml b/slices/dbus-daemon.yaml new file mode 100644 index 000000000..6160a56da --- /dev/null +++ b/slices/dbus-daemon.yaml @@ -0,0 +1,31 @@ +package: dbus-daemon + +essential: + - dbus-daemon_copyright + +slices: + bins: + essential: + - dbus-bin_bins + - dbus-daemon_config + - dbus-session-bus-common_config + - libapparmor1_libs + - libaudit1_libs + - libc6_libs + - libcap-ng0_libs + - libdbus-1-3_libs + - libexpat1_libs + - libselinux1_libs + - libsystemd0_libs + contents: + /usr/bin/dbus-daemon: + /usr/bin/dbus-run-session: + /var/lib/dbus/: { make: true, mode: 0755 } + + config: + contents: + /usr/lib/tmpfiles.d/dbus.conf: + + copyright: + contents: + /usr/share/doc/dbus-daemon/copyright: diff --git a/slices/dbus-session-bus-common.yaml b/slices/dbus-session-bus-common.yaml new file mode 100644 index 000000000..08f2beb74 --- /dev/null +++ b/slices/dbus-session-bus-common.yaml @@ -0,0 +1,14 @@ +package: dbus-session-bus-common + +essential: + - dbus-session-bus-common_copyright + +slices: + config: + contents: + /etc/dbus-1/session.d/: + /usr/share/dbus-1/session.conf: + + copyright: + contents: + /usr/share/doc/dbus-session-bus-common/copyright: diff --git a/slices/dbus-system-bus-common.yaml b/slices/dbus-system-bus-common.yaml new file mode 100644 index 000000000..009de842e --- /dev/null +++ b/slices/dbus-system-bus-common.yaml @@ -0,0 +1,23 @@ +package: dbus-system-bus-common + +essential: + - dbus-system-bus-common_copyright + +slices: + # Depends on adduser, however it's used by the dbus postinst + # to create the following user: + # 'messagebus' without a home directory and disabled password + config: + contents: + /etc/dbus-1/system.d/: + /usr/lib/sysusers.d/dbus.conf: + /usr/share/dbus-1/system.conf: + + services: + contents: + /usr/lib/systemd/system/dbus.socket: + /usr/lib/systemd/system/sockets.target.wants/dbus.socket: + + copyright: + contents: + /usr/share/doc/dbus-system-bus-common/copyright: diff --git a/slices/dbus.yaml b/slices/dbus.yaml new file mode 100644 index 000000000..7980b05ce --- /dev/null +++ b/slices/dbus.yaml @@ -0,0 +1,35 @@ +package: dbus + +essential: + - dbus_copyright + +slices: + bins: + essential: + - dbus-bin_bins + - dbus-daemon_bins + - dbus-system-bus-common_config + - dbus_config + - libc6_libs + - libdbus-1-3_libs + - libexpat1_libs + - libsystemd0_libs + contents: + /etc/init.d/dbus: + /usr/lib/dbus-*/dbus-daemon-launch-helper: + + config: + contents: + /etc/default/dbus: + + services: + essential: + - dbus-system-bus-common_services + - dbus_bins + contents: + /usr/lib/systemd/system/dbus.service: + /usr/lib/systemd/system/multi-user.target.wants/dbus.service: + + copyright: + contents: + /usr/share/doc/dbus/copyright: diff --git a/slices/libdbus-1-3.yaml b/slices/libdbus-1-3.yaml new file mode 100644 index 000000000..5f5a15cb8 --- /dev/null +++ b/slices/libdbus-1-3.yaml @@ -0,0 +1,16 @@ +package: libdbus-1-3 + +essential: + - libdbus-1-3_copyright + +slices: + libs: + essential: + - libc6_libs + - libsystemd0_libs + contents: + /usr/lib/*-linux-*/libdbus-1.so.3*: + + copyright: + contents: + /usr/share/doc/libdbus-1-3/copyright: diff --git a/tests/spread/integration/dbus/task.yaml b/tests/spread/integration/dbus/task.yaml new file mode 100644 index 000000000..3dad4e60a --- /dev/null +++ b/tests/spread/integration/dbus/task.yaml @@ -0,0 +1,20 @@ +summary: Integration tests for dbus + +execute: | + # Chisel a minimum number of slices to give us a runnable system that we can + # test in. + rootfs="$(install-slices base-files_base bash_bins coreutils_bins passwd_config dbus_bins)" + + # we need /dev/null for testing + mkdir "${rootfs}"/dev + mount --bind /dev "${rootfs}"/dev + + # we also need a messagebus user + useradd -R "${rootfs}" -c "dbus messagebus test user" -u 1234 -g 1 -M messagebus + + cp test.sh "${rootfs}/" + chroot "${rootfs}/" /test.sh + + # cleanup the daemon and mount + pkill -9 -f dbus-daemon + umount "${rootfs}"/dev diff --git a/tests/spread/integration/dbus/test.sh b/tests/spread/integration/dbus/test.sh new file mode 100755 index 000000000..4e4e875a0 --- /dev/null +++ b/tests/spread/integration/dbus/test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# First thing is to create a system uuid +mkdir -p /var/lib/dbus/ +dbus-uuidgen > /var/lib/dbus/machine-id + +# Start the daemon +mkdir -p /run/dbus +dbus-daemon --system + +# Test by sending, but allow a moment for the service to get up +sleep 1 +dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames