From 3701553a44284c763cc204d2f4ee5008c408b691 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Sat, 10 May 2025 21:33:41 +0800 Subject: [PATCH] change user and group creation into systemd style --- dovecot.spec | 34 ++++++++++++++++------------------ dovecot.sysusers | 9 +++++++++ 2 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 dovecot.sysusers diff --git a/dovecot.spec b/dovecot.spec index 35e05bd..4bbf57a 100644 --- a/dovecot.spec +++ b/dovecot.spec @@ -6,7 +6,7 @@ Name: dovecot Version: 2.3.21.1 -Release: 3 +Release: 4 Summary: Dovecot Secure imap server License: MIT AND LGPL-2.1-only URL: https://www.dovecot.org/ @@ -21,6 +21,7 @@ Source9: dovecot.sysconfig Source10: dovecot.tmpfilesd Source11: prestartscript Source12: dovecot.conf.5 +Source16: dovecot.sysusers Patch0: dovecot-2.0-defaultconfig.patch Patch1: dovecot-1.0.beta2-mkcert-permissions.patch @@ -49,10 +50,8 @@ BuildRequires: lz4-devel libzstd-devel libicu-devel libstemmer-devel multilib-rp BuildRequires: systemd-devel chrpath Requires: openssl >= 0.9.7f-4 systemd tar -Requires(pre): shadow-utils -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units +%{?sysusers_requires_compat} +%{?systemd_requires} Provides: %{name}-pigeonhole = 1:%{version}-%{release} %{name}-pgsql = 1:%{version}-%{release} Obsoletes: %{name}-pigeonhole < 1:%{version}-%{release} %{name}-pgsql < 1:%{version}-%{release} @@ -87,13 +86,13 @@ export CFLAGS="%{__global_cflags} -fno-strict-aliasing" LDFLAGS="%{?__global_ldf %endif mkdir -p m4 -autoreconf -I . -fiv #required for aarch64 support +autoreconf -I. -I%{_datadir}/gettext/m4 -fiv #required for aarch64 support %configure INSTALL_DATA="install -c -p -m644" \ --docdir=%{_docdir}/%{name} --disable-static --disable-rpath --with-nss \ --with-shadow --with-pam --with-gssapi=plugin --with-ldap=plugin --with-sql=plugin --with-pgsql --with-mysql \ --with-sqlite --with-zlib --with-libcap --with-lucene --with-ssl=openssl --with-ssldir=%{ssldir} \ - --with-solr --with-systemdsystemunitdir=%{_unitdir} --with-docs + --with-solr --with-docs sed -i 's|/etc/ssl|/etc/pki/dovecot|' doc/mkcert.sh doc/example-config/conf.d/10-ssl.conf @@ -125,6 +124,7 @@ cd - install -p -D -m 644 %{S:2} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/dovecot install -p -D -m 644 %{S:12} $RPM_BUILD_ROOT%{_mandir}/man5/dovecot.conf.5 install -p -D -m 755 %{S:11} $RPM_BUILD_ROOT%{_libexecdir}/dovecot/prestartscript +install -p -D -m 0644 %{S:16} $RPM_BUILD_ROOT%{_sysusersdir}/dovecot.conf install -d $RPM_BUILD_ROOT%{ssldir}/certs install -d $RPM_BUILD_ROOT%{ssldir}/private @@ -167,13 +167,7 @@ echo "%{_libdir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.co echo "%{_libdir}/%{name}/old-stats" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf %pre -getent group dovecot >/dev/null || groupadd -r --gid 97 dovecot -getent passwd dovecot >/dev/null || \ -useradd -r --uid 97 -g dovecot -d /usr/libexec/dovecot -s /sbin/nologin -c "Dovecot IMAP server" dovecot - -getent group dovenull >/dev/null || groupadd -r dovenull -getent passwd dovenull >/dev/null || \ -useradd -r -g dovenull -d /usr/libexec/dovecot -s /sbin/nologin -c "Dovecot's unauthorized user" dovenull +%sysusers_create_compat %{S:16} if [ "$1" = "2" ]; then rm -f %restart_flag @@ -182,6 +176,7 @@ if [ "$1" = "2" ]; then fi %post +/sbin/ldconfig if [ $1 -eq 1 ]; then %systemd_post dovecot.service fi @@ -200,6 +195,7 @@ if [ $1 = 0 ]; then fi %postun +/sbin/ldconfig /bin/systemctl daemon-reload >/dev/null 2>&1 || : @@ -214,10 +210,12 @@ if [ -e %restart_flag ]; then rm -f %restart_flag fi +%ifnarch aarch64 %check make check cd dovecot-2*3-pigeonhole-%{pigeonholever} make check +%endif %files %license COPYING COPYING.LGPL COPYING.MIT @@ -227,6 +225,7 @@ make check %{_bindir}/{doveadm,doveconf,dsync,dovecot-sysreport} %_tmpfilesdir/dovecot.conf +%{_sysusersdir}/dovecot.conf %{_unitdir}/{dovecot.service,dovecot.socket,dovecot-init.service} %dir %{_sysconfdir}/dovecot @@ -256,7 +255,6 @@ make check %exclude %{_libdir}/dovecot/doveadm/*sieve* %{_libdir}/dovecot/*.so.* %{_libdir}/dovecot/*_plugin.so -%{_libdir}/dovecot/*_sieve_plugin.so %{_libdir}/dovecot/auth/{lib20_auth_var_expand_crypt.so,libauthdb_imap.so,libauthdb_ldap.so} %{_libdir}/dovecot/auth/{libmech_gssapi.so,libdriver_sqlite.so} %{_libdir}/dovecot/dict/{libdriver_sqlite.so,libdict_ldap.so} @@ -278,10 +276,7 @@ make check %{_docdir}/%{name}-pigeonhole -%{_libexecdir}/%{name}/{managesieve,managesieve-login} - %{_libdir}/dovecot/doveadm/*sieve* -%{_libdir}/dovecot/*_sieve_plugin.so %{_libdir}/dovecot/settings/{libmanagesieve_*.so,libpigeonhole_*.so} %{_libdir}/dovecot/sieve/ %{_libdir}/%{name}/libdriver_mysql.so @@ -310,6 +305,9 @@ make check %changelog +* Sat May 10 2025 Funda Wang - 1:2.3.21.1-4 +- change user and group creation into systemd style + * Sun Oct 27 2024 Funda Wang - 1:2.3.21.1-3 - link with icu-uc for icu >= 76 diff --git a/dovecot.sysusers b/dovecot.sysusers new file mode 100644 index 0000000..c286ee4 --- /dev/null +++ b/dovecot.sysusers @@ -0,0 +1,9 @@ +#Type Name ID GECOS Home directory Shell +g dovecot 97 +u dovecot 97 "Dovecot IMAP server" /usr/libexec/dovecot /sbin/nologin +m dovecot dovecot + +g dovenull - +u dovenull - "Dovecot - unauthorized user" /usr/libexec/dovecot /sbin/nologin +m dovenull dovenull + -- Gitee