summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2025-02-15 07:59:59 +0100
committerRemi Collet <remi@php.net>2025-02-15 07:59:59 +0100
commit22a5372cf24b0d2e26aa74948b2e797ac880dfc3 (patch)
tree67c20e4d53c2db6f7e29804fd4f968391bbe6e10
parent2fa59b25089bcaaa48781e636e58c4d6b184f49a (diff)
add a sysusers.d file (Fedora and EL >= 9)HEADmaster
add a sysusers.d file (Fedora and EL >= 9)
-rw-r--r--unit.spec30
-rw-r--r--unit.sysusers1
2 files changed, 29 insertions, 2 deletions
diff --git a/unit.spec b/unit.spec
index 5ec0d57..c07b3b0 100644
--- a/unit.spec
+++ b/unit.spec
@@ -14,6 +14,12 @@
%bcond_with wasm
# need vendored rust libraries
%bcond_without otel
+%if 0%{?fedora} || 0%{?rhel} >= 9
+# RPM 4.19 feature
+%bcond_without sysusers
+%else
+%bcond_with sysusers
+%endif
%global gh_owner nginx
%global project unit
@@ -23,7 +29,7 @@
Name: unit
Summary: NGINX Unit application server
Version: 1.34.1
-Release: 2%{?dist}
+Release: 3%{?dist}
# unit is Apache-2.0
# rust libraries are Apache-2.0 or MIT
License: Apache-2.0 AND MIT
@@ -37,6 +43,7 @@ Source4: unit.logrotate
# awfull hack, use a bundled rust registry
Source5: makedeps.sh
Source6: %{project}-deps-%{version}.tgz
+Source7: unit.sysusers
BuildRequires: make
BuildRequires: gcc
@@ -54,9 +61,14 @@ BuildRequires: rust >= 1.73
BuildRequires: clang
BuildRequires: llvm
%endif
+BuildRequires: systemd-rpm-macros
%{?systemd_ordering}
+%if %{with sysusers}
+%{?sysusers_requires_compat}
+%else
Requires(pre): /usr/sbin/useradd
+%endif
Requires: logrotate
Provides: nginx-unit = %{version}-%{release}
@@ -194,6 +206,10 @@ install -m 644 pkg/contrib/libunit-wasm/src/c/libunit-wasm.a %{buildroot}%{_libd
install -m 644 pkg/contrib/libunit-wasm/src/c/include/unit/unit-wasm.h %{buildroot}%{_includedir}/unit/
%endif
+%if %{with sysusers}
+install -p -D -m 0644 %{SOURCE7} %{buildroot}%{_sysusersdir}/unit.conf
+%endif
+
%check
%if %{with tests}
@@ -203,10 +219,14 @@ make tests %{?_smp_mflags} E=0 V=1
%pre
+%if %{with sysusers}
+%sysusers_create_compat %{SOURCE7}
+%else
getent group unit >/dev/null || groupadd -r unit
getent passwd unit >/dev/null || \
useradd -r -g unit -s /sbin/nologin \
- -d /nonexistent -c "unit user" unit
+ -d /nonexistent -c "NGINX Unit user" unit
+%endif
%post
%systemd_post %{name}.service
@@ -252,6 +272,9 @@ BANNER
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}-debug.service
%dir %attr(0755,root,root) %ghost /run/%{name}
+%if %{with sysusers}
+%{_sysusersdir}/%{name}.conf
+%endif
%files devel
@@ -268,6 +291,9 @@ BANNER
%changelog
+* Sat Feb 15 2025 Remi Collet <remi@remirepo.net> - 1.34.1-3
+- add a sysusers.d file (Fedora and EL >= 9)
+
* Fri Feb 14 2025 Remi Collet <remi@remirepo.net> - 1.34.1-2
- F42: workaround /usr/sbin merged in /usr/bin
- add unit-debug service
diff --git a/unit.sysusers b/unit.sysusers
new file mode 100644
index 0000000..66c23d1
--- /dev/null
+++ b/unit.sysusers
@@ -0,0 +1 @@
+u unit - "NGINX Unit user" /dev/null /sbin/nologin