spec: package SELinux policy
This installs a dbus-broker SELinux policy module with the package, which
is needed in order to run dbus-broker with SELinux in enforcing mode.
@@ -16,6 +16,7 @@ BuildRequires: libselinux-devel
BuildRequires: meson
BuildRequires: ninja-build
BuildRequires: systemd-devel
+BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp
%description
Linux D-Bus Message Broker
@@ -27,9 +28,25 @@ Linux D-Bus Message Broker
git clone --recurse-submodules https://github.com/bus1/dbus-broker.git
meson --prefix=/usr --buildtype=release "dbus-broker" "build"
ninja -v -C "build"
+mkdir build/selinux
+cp selinux/dbus-broker.{te,fc} build/selinux/
+cd build/selinux
+make NAME=targeted -f /usr/share/selinux/devel/Makefile
+cd -
%install
DESTDIR=$RPM_BUILD_ROOT ninja -v -C "build" install
+install -d %{buildroot}%{_datadir}/selinux/targeted
+install -p -m 644 build/selinux/dbus-broker.pp %{buildroot}%{_datadir}/selinux/targeted/dbus-broker.pp
+
+%post
+/usr/sbin/semodule -s targeted -i %{_datadir}/selinux/targeted/dbus-broker.pp
+/sbin/fixfiles -R dbus-broker restore
+
+%postun
+if [ $1 -eq 0 ] ; then
+ /usr/sbin/semodule -s targeted -r dbus-broker
+fi
%files
#%license AUTHORS
@@ -37,6 +54,7 @@ DESTDIR=$RPM_BUILD_ROOT ninja -v -C "build" install
#%license LICENSE
%{_bindir}/dbus-broker
%{_bindir}/dbus-broker-launch
+%{_datadir}/selinux/*/dbus-broker.pp
%{_unitdir}/%{name}.service
%{_userunitdir}/%{name}.service
