Use systemd-sysusers for cyrus user and group

Resolves: #2095381
This commit is contained in:
Martin Osvald 2023-08-01 13:20:41 +02:00
parent cb0a4a80f5
commit d3352acaa2
2 changed files with 17 additions and 5 deletions

View File

@ -14,7 +14,7 @@
Name: cyrus-imapd
Version: 3.4.1
Release: 9%{?dist}
Release: 10%{?dist}
%define ssl_pem_file_prefix /etc/pki/%name/%name
@ -70,6 +70,7 @@ Source15: README.rpm
Source16: cyrus-imapd.service
Source17: cyrus-imapd-init.service
Source18: cyrus-imapd.tmpfiles.conf
Source19: cyrus-imapd.sysusers
# Source files for running the Cassandane test suite at build time.
Source80: https://github.com/cyrusimap/cassandane/archive/%cocas/cassandane-${cocas_short}.tar.gz#/cassandane-%{scmt %cocas}.tar.gz
@ -109,6 +110,8 @@ BuildRequires: python3-sphinx
# Miscellaneous modules needed for 'make check' to function:
BuildRequires: cyrus-sasl-plain cyrus-sasl-md5
BuildRequires: systemd-rpm-macros
%if %{with cassandane}
# Additional packages required for cassandane to function
BuildRequires: imaptest net-tools words
@ -155,6 +158,7 @@ BuildRequires: make
Requires(pre): shadow-utils
%{?systemd_requires}
%{?sysusers_requires_compat}
Requires: cyrus-imapd-libs%{?_isa} = %{version}-%{release}
Requires: cyrus-imapd-utils = %{version}-%{release}
@ -413,6 +417,8 @@ install -p -m 644 doc/examples/imapd_conf/normal.conf %buildroot/etc/imapd.conf
install -p -D -m 644 %SOURCE16 %buildroot/%_unitdir/cyrus-imapd.service
install -p -D -m 644 %SOURCE17 %buildroot/%_unitdir/cyrus-imapd-init.service
install -p -D -m 644 %SOURCE18 %buildroot/%_tmpfilesdir/cyrus-imapd.conf
# systemd-sysusers
install -p -D -m 644 %{SOURCE19} %{buildroot}%{_sysusersdir}/cyrus-imapd.conf
# Cleanup of doc dir
find doc perl -name CVS -type d -prune -exec rm -rf {} \;
@ -551,10 +557,7 @@ exclude+=("!Master.maxforkrate")
%pre
# Create 'cyrus' user on target host
getent group saslauth >/dev/null || /usr/sbin/groupadd -g %gid -r saslauth
getent passwd cyrus >/dev/null || /usr/sbin/useradd -c "Cyrus IMAP Server" -d /var/lib/imap -g %cyrusgroup \
-G saslauth -s /sbin/nologin -u %uid -r %cyrususer
%sysusers_create_compat %{SOURCE19}
%post
%systemd_post cyrus-imapd.service
@ -596,6 +599,7 @@ getent passwd cyrus >/dev/null || /usr/sbin/useradd -c "Cyrus IMAP Server" -d /v
%_unitdir/cyrus-imapd.service
%_unitdir/cyrus-imapd-init.service
%_tmpfilesdir/cyrus-imapd.conf
%{_sysusersdir}/cyrus-imapd.conf
%dir %cyrexecdir/
%cyrexecdir/[a-uw-z]*
@ -667,6 +671,9 @@ getent passwd cyrus >/dev/null || /usr/sbin/useradd -c "Cyrus IMAP Server" -d /v
%changelog
* Tue Aug 01 2023 Martin Osvald <mosvald@redhat.com> - 3.4.1-10
- Resolves: #2095381 - Use systemd-sysusers for cyrus user and group
* Tue Aug 01 2023 Martin Osvald <mosvald@redhat.com> - 3.4.1-9
- Resolves: #2228035 - Fix rpminspect CI errors

5
cyrus-imapd.sysusers Normal file
View File

@ -0,0 +1,5 @@
#Type Name ID GECOS Home directory Shell
g saslauth 76
g mail 12
u cyrus 76:mail "Cyrus IMAP Server" /var/lib/imap /sbin/nologin
m cyrus saslauth