Use systemd sysusers to create saslauth user

Signed-off-by: Simo Sorce <simo@redhat.com>
This commit is contained in:
Simo Sorce 2022-06-09 13:34:27 -04:00
parent de822fc001
commit 7f6beb682b
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,4 @@
%global username saslauth
%global hint Saslauthd user
%global homedir /run/saslauthd
%global _plugindir2 %{_libdir}/sasl2
%global bootstrap_cyrus_sasl 0
@ -17,6 +15,7 @@ URL: https://www.cyrusimap.org/sasl/
# make-no-dlcompatorsrp-tarball.sh removes the "dlcompat" subdirectory and builds a
# new tarball.
Source0: cyrus-sasl-%{version}-nodlcompatorsrp.tar.gz
Source3: saslauth.sysusers
Source5: saslauthd.service
Source7: sasl-mechlist.c
Source9: saslauthd.sysconfig
@ -25,6 +24,7 @@ Source10: make-no-dlcompatorsrp-tarball.sh
# https://raw.githubusercontent.com/cyrusimap/cyrus-sasl/master/autogen.sh
Source11: autogen.sh
Requires: %{name}-lib%{?_isa} = %{version}-%{release}
Patch11: cyrus-sasl-2.1.25-no_rpath.patch
Patch15: cyrus-sasl-2.1.20-saslauthd.conf-path.patch
@ -304,6 +304,9 @@ install -m755 -d $RPM_BUILD_ROOT/%{_plugindir2}
./libtool --mode=install \
install -m755 lib/sasl2-shared-mechlist $RPM_BUILD_ROOT/%{_sbindir}/
# Sysusers file
install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/cyrus-sasl.conf
# Remove unpackaged files from the buildroot.
rm -f $RPM_BUILD_ROOT%{_libdir}/sasl2/libotp.*
rm -f $RPM_BUILD_ROOT%{_libdir}/sasl2/*.a
@ -315,8 +318,7 @@ rm -f $RPM_BUILD_ROOT%{_mandir}/cat8/saslauthd.8
make check %{?_smp_mflags}
%pre
getent group %{username} >/dev/null || groupadd -g 76 -r %{username}
getent passwd %{username} >/dev/null || useradd -r -g %{username} -d %{homedir} -s /sbin/nologin -c "%{hint}" %{username}
%sysusers_create_compat %{SOURCE3}
%post
%systemd_post saslauthd.service
@ -338,6 +340,7 @@ getent passwd %{username} >/dev/null || useradd -r -g %{username} -d %{homedir}
%config(noreplace) /etc/sysconfig/saslauthd
%{_unitdir}/saslauthd.service
%ghost /run/saslauthd
%{_sysusersdir}/cyrus-sasl.conf
%files lib
%license COPYING

4
saslauth.sysusers Normal file
View File

@ -0,0 +1,4 @@
#Type Name ID GECOS Home directory Shell
g saslauth 76
u saslauth - "Saslauthd user" /run/saslauthd /sbin/nologin
m saslauth saslauth