Name: postsrsd2 Version: 2.0.11 Release: 1%{?dist} Summary: Sender Rewriting Scheme (SRS) provider for Postfix Conflicts: postsrsd License: GPL-3.0-only AND BSD-3-Clause AND FSFUL URL: https://github.com/roehling/postsrsd Source0: https://github.com/roehling/postsrsd/archive/%{version}/postsrsd-%{version}.tar.gz # SELinux policy source files Source1: postsrsd.te Source2: postsrsd.fc Source3: postsrsd.if BuildRequires: gcc BuildRequires: cmake BuildRequires: make BuildRequires: libconfuse-devel BuildRequires: systemd-rpm-macros # SELinux policy build requirements BuildRequires: selinux-policy-devel %{?selinux_requires_policy_build} %{?systemd_requires} Requires(post): policycoreutils Requires(preun): policycoreutils Requires(postun): policycoreutils Requires: logrotate %description PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based lookup tables for Postfix. SRS is needed if your mail server acts as forwarder. This is version 2.x of postsrsd, packaged as postsrsd2. %prep %autosetup -n postsrsd-%{version} # SELinux files setup mkdir selinux cp %{SOURCE1} %{SOURCE2} %{SOURCE3} selinux/ %build # RHEL 9/10 style cmake build %cmake \ -DCMAKE_BUILD_TYPE=Release \ -DSYSCONF_DIR=%{_sysconfdir} \ -DGENERATE_SRS_SECRET=OFF \ -DUSE_SELINUX=ON \ -DINIT_FLAVOR=systemd %cmake_build # Build SELinux policy cd selinux make -f %{_datadir}/selinux/devel/Makefile postsrsd.pp %install %cmake_install # Install SELinux policy install -d %{buildroot}%{_datadir}/selinux/packages/%{name} install -m 0644 selinux/postsrsd.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/ # Ensure runtime directory exists (systemd handles this usually, but good for packaging) mkdir -p %{buildroot}/run/postsrsd %pre # Create postsrsd user/group if strictly needed (daemon usually runs as dynamic user or nobody depending on config) # 2.x usually relies on systemd DynamicUser or a specific user created here. getent group postsrsd >/dev/null || groupadd -r postsrsd getent passwd postsrsd >/dev/null || \ useradd -r -g postsrsd -d /run/postsrsd -s /sbin/nologin \ -c "PostSRSd system user" postsrsd exit 0 %post %systemd_post postsrsd.service # Install SELinux module if [ "$1" -le "1" ] ; then # First install semodule -i %{_datadir}/selinux/packages/%{name}/postsrsd.pp 2>/dev/null || : fixfiles -R %{name} restore || : # Apply context to configuration directory specifically restorecon -R %{_sysconfdir}/postsrsd || : fi %preun %systemd_preun postsrsd.service if [ "$1" -eq 0 ] ; then # Final removal semodule -r postsrsd 2>/dev/null || : fi %postun %systemd_postun_with_restart postsrsd.service if [ "$1" -ge 1 ] ; then # Upgrade semodule -i %{_datadir}/selinux/packages/%{name}/postsrsd.pp 2>/dev/null || : fixfiles -R %{name} restore || : fi %files %license LICENSE %doc README.md %dir %{_sysconfdir}/postsrsd %config(noreplace) %{_sysconfdir}/postsrsd/postsrsd.conf %{_sbindir}/postsrsd %{_unitdir}/postsrsd.service %{_mandir}/man8/postsrsd.8* %{_datadir}/selinux/packages/%{name}/postsrsd.pp # 2.x might install other docs or examples, check build output if necessary %changelog * Wed Nov 20 2024 User Name - 2.0.11-1 - Initial package for postsrsd 2.x (named postsrsd2) - Added SELinux policies - Updated dependencies for RHEL 10