Switch to sysusers_ctl instead of useradd

Resolves: #2095417
This commit is contained in:
DJ Delorie 2023-05-08 23:39:39 -04:00
parent 17e18d1a08
commit 7afefa800d
2 changed files with 16 additions and 11 deletions

View File

@ -155,7 +155,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 67%{?dist}
Release: 68%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -195,6 +195,7 @@ Source10: wrap-find-debuginfo.sh
Source11: parse-SUPPORTED.py
# Include in the source RPM for reference.
Source12: ChangeLog.old
Source13: nscd-sysusers.conf
######################################################################
# Activate the wrapper script for debuginfo generation, by rewriting
@ -773,7 +774,7 @@ BuildRequires: valgrind
%endif
# We use systemd rpm macros for nscd
BuildRequires: systemd
BuildRequires: systemd systemd-rpm-macros
# We use python for the microbenchmarks and locale data regeneration
# from unicode sources (carried out manually). We choose python3
@ -1416,10 +1417,10 @@ Requires: %{name} = %{version}-%{release}
Requires: libselinux >= 1.17.10-1
%endif
Requires: audit-libs >= 1.1.3
Requires(pre): /usr/sbin/useradd, coreutils
Requires(pre): systemd, coreutils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd, /usr/sbin/userdel
Requires(postun): systemd
%description -n nscd
The nscd daemon caches name service lookups and can improve
@ -1832,6 +1833,8 @@ install_different "$RPM_BUILD_ROOT/%{_libdir}/glibc-hwcaps" power10 ..
popd
%endif
install -p -D -m 0644 %{SOURCE13} ${RPM_BUILD_ROOT}%{_sysusersdir}/nscd.conf
##############################################################################
# Remove the files we don't want to distribute
##############################################################################
@ -2763,10 +2766,8 @@ update_gconv_modules_cache ()
update_gconv_modules_cache ()
%pre -n nscd
getent group nscd >/dev/null || /usr/sbin/groupadd -g 28 -r nscd
getent passwd nscd >/dev/null ||
/usr/sbin/useradd -M -o -r -d / -s /sbin/nologin \
-c "NSCD Daemon" -u 28 -g nscd nscd
# install user nscd(28) and group nscd(28)
%sysusers_create_compat %{SOURCE13}
%post -n nscd
%systemd_post nscd.service
@ -2775,9 +2776,6 @@ getent passwd nscd >/dev/null ||
%systemd_preun nscd.service
%postun -n nscd
if test $1 = 0; then
/usr/sbin/userdel nscd > /dev/null 2>&1 || :
fi
%systemd_postun_with_restart nscd.service
%files -f glibc.filelist
@ -2854,6 +2852,7 @@ fi
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/hosts
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/services
%ghost %config(missingok,noreplace) /etc/sysconfig/nscd
%{_sysusersdir}/nscd.conf
%files -f nss_db.filelist -n nss_db
/var/db/Makefile
@ -2876,6 +2875,9 @@ fi
%endif
%changelog
* Mon May 08 2023 DJ Delorie <dj@redhat.com> - 2.34-68
- Switch to sysusers_ctl instead of useradd (#2095417)
* Fri Apr 28 2023 Florian Weimer <fweimer@redhat.com> - 2.34-67
- Sync with upstream branch release/2.34/master,
commit 0ea8174d62263c2679c95c0d215d2627e560f7aa:

3
nscd-sysusers.conf Normal file
View File

@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
g nscd 28
u nscd 28 "NSCD Daemon" - -