summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--memcached.conf1
-rw-r--r--memcached.spec37
2 files changed, 32 insertions, 6 deletions
diff --git a/memcached.conf b/memcached.conf
new file mode 100644
index 0000000..6148205
--- /dev/null
+++ b/memcached.conf
@@ -0,0 +1 @@
+u memcached - "memcached daemon" -
diff --git a/memcached.spec b/memcached.spec
index ea9bf4d..92326e9 100644
--- a/memcached.spec
+++ b/memcached.spec
@@ -25,6 +25,11 @@
%else
%bcond_with selinux
%endif
+%if 0%{?fedora} >= 35 || 0%{?rhel} >= 9
+%bcond_without sysusers
+%else
+%bcond_with sysusers
+%endif
# disable testing as it is unreliable on build systems
%bcond_with tests
@@ -37,7 +42,7 @@
Name: memcached
Version: 1.6.15
-Release: 1%{?dist}
+Release: 2%{?dist}
Epoch: 0
Summary: High Performance, Distributed Memory Object Cache
@@ -47,9 +52,10 @@ Source0: https://www.memcached.org/files/%{name}-%{version}.tar.gz
Source1: memcached.sysconfig
# SELinux policy sources: https://pagure.io/memcached-selinux/tree/master
Source2: https://releases.pagure.org/memcached-selinux/memcached-selinux-1.0.2.tar.gz
-
-# custom unit file
-Source3: memcached.service
+# systemd users
+Source3: memcached.conf
+# custom unit file (EL-7)
+Source4: memcached.service
Patch1: memcached-unit.patch
@@ -69,9 +75,14 @@ BuildRequires: libseccomp-devel
%if %{with tls}
BuildRequires: openssl-devel >= 1.1
%endif
+%if %{with sysusers}
+%sysusers_requires_compat
+BuildRequires: systemd-rpm-macros
+%else
+Requires(pre): shadow-utils
+%endif
%{?systemd_requires}
-Requires(pre): shadow-utils
%if %{with selinux}
# Rich dependency syntax - require selinux policy subpackage
# when selinux-policy-targeted is installed
@@ -169,7 +180,7 @@ install -Dp -m0644 scripts/memcached-tool.1 \
# Unit file
%if 0%{?fedora} < 25 && 0%{?rhel} < 8
-install -Dp -m0644 %{SOURCE3} %{buildroot}%{_unitdir}/memcached.service
+install -Dp -m0644 %{SOURCE4} %{buildroot}%{_unitdir}/memcached.service
%else
install -Dp -m0644 scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%endif
@@ -211,6 +222,10 @@ touch -r %{SOURCE1} %{buildroot}/%{_sysconfdir}/sysconfig/%{name}
install -Dp -m0644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/sysconfig/%{name}
%endif
+%if %{with sysusers}
+install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/memcached.conf
+%endif
+
%if %{with selinux}
%pre selinux
@@ -230,10 +245,14 @@ fi
%endif
%pre
+%if %{with sysusers}
+%sysusers_create_compat %{SOURCE3}
+%else
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || \
useradd -r -g %{groupname} -d /run/memcached \
-s /sbin/nologin -c "Memcached daemon" %{username}
+%endif
exit 0
@@ -260,6 +279,9 @@ exit 0
%{_mandir}/man1/memcached.1*
%{_unitdir}/memcached.service
%{_unitdir}/memcached@.service
+%if %{with sysusers}
+%{_sysusersdir}/memcached.conf
+%endif
%files devel
@@ -276,6 +298,9 @@ exit 0
%changelog
+* Thu Jun 23 2022 Remi Collet <remi@remirepo.net> - 1.6.15-2
+- modernize dynamic user management (from Fedora)
+
* Mon Apr 4 2022 Remi Collet <remi@remirepo.net> - 1.6.15-1
- update to 1.6.15