Use systemd-sysusers

Resolves: RHEL-6770 - [RFE] nginx use systemd-sysusers
This commit is contained in:
Luboš Uhliarik 2025-02-05 18:28:49 +01:00
parent ea558a61dd
commit 3ac52f1966
2 changed files with 12 additions and 9 deletions

View File

@ -85,6 +85,7 @@ Source15: macros.nginxmods.in
Source16: nginxmods.attr Source16: nginxmods.attr
Source17: nginx-ssl-pass-dialog Source17: nginx-ssl-pass-dialog
Source18: nginx@.service Source18: nginx@.service
Source19: nginx.sysusers
Source102: nginx-logo.png Source102: nginx-logo.png
Source200: README.dynamic Source200: README.dynamic
Source210: UPGRADE-NOTES-1.6-to-1.10 Source210: UPGRADE-NOTES-1.6-to-1.10
@ -142,9 +143,9 @@ Recommends: logrotate
Requires: %{name}-core = %{epoch}:%{version}-%{release} Requires: %{name}-core = %{epoch}:%{version}-%{release}
BuildRequires: systemd BuildRequires: systemd
Requires(post): systemd BuildRequires: systemd-rpm-macros
Requires(preun): systemd %{?systemd_requires}
Requires(postun): systemd
# For external nginx modules # For external nginx modules
Provides: nginx(abi) = %{nginx_abiversion} Provides: nginx(abi) = %{nginx_abiversion}
@ -184,7 +185,7 @@ Meta package that installs all available nginx modules.
%package filesystem %package filesystem
Summary: The basic directory layout for the Nginx server Summary: The basic directory layout for the Nginx server
BuildArch: noarch BuildArch: noarch
Requires(pre): shadow-utils %{?sysusers_requires_compat}
%description filesystem %description filesystem
The nginx-filesystem package contains the basic directory layout The nginx-filesystem package contains the basic directory layout
@ -488,13 +489,11 @@ mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
install -m755 $RPM_SOURCE_DIR/nginx-ssl-pass-dialog \ install -m755 $RPM_SOURCE_DIR/nginx-ssl-pass-dialog \
$RPM_BUILD_ROOT%{_libexecdir}/nginx-ssl-pass-dialog $RPM_BUILD_ROOT%{_libexecdir}/nginx-ssl-pass-dialog
# install sysusers file
install -p -D -m 0644 %{SOURCE19} %{buildroot}%{_sysusersdir}/nginx.conf
%pre filesystem %pre filesystem
getent group %{nginx_user} > /dev/null || groupadd -r %{nginx_user} %sysusers_create_compat %{SOURCE19}
getent passwd %{nginx_user} > /dev/null || \
useradd -r -d %{_localstatedir}/lib/nginx -g %{nginx_user} \
-s /sbin/nologin -c "Nginx web server" %{nginx_user}
exit 0
%post %post
%systemd_post nginx.service %systemd_post nginx.service
@ -597,6 +596,7 @@ fi
%dir %{_sysconfdir}/nginx/default.d %dir %{_sysconfdir}/nginx/default.d
%dir %{_sysconfdir}/systemd/system/nginx.service.d %dir %{_sysconfdir}/systemd/system/nginx.service.d
%dir %{_unitdir}/nginx.service.d %dir %{_unitdir}/nginx.service.d
%{_sysusersdir}/nginx.conf
%if %{with geoip} %if %{with geoip}
%files mod-http-geoip %files mod-http-geoip

3
nginx.sysusers Normal file
View File

@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
g nginx -
u nginx - "Nginx web server" /var/lib/nginx /sbin/nologin