Use systemd-sysusers for user creation

Patch taken from fedora/tpm2-tss commit 9608d38.

Resolves: rhbz#2095479

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
This commit is contained in:
Štěpán Horáček 2023-04-04 15:18:32 +02:00
parent f76eab2dc2
commit 07e8317a65
2 changed files with 7 additions and 8 deletions

View File

@ -0,0 +1,2 @@
#Type Name ID GECOS Home directory Shell
u tss 59 "Account used for TPM access" - -

View File

@ -8,6 +8,7 @@ Summary: TPM2.0 Software Stack
License: BSD and TCGL
URL: https://github.com/tpm2-software/tpm2-tss
Source0: https://github.com/tpm2-software/tpm2-tss/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1: tpm2-tss-systemd-sysusers.conf
# doxygen crash
Patch0: tpm2-tss-3.0.0-doxygen.patch
# OpenSSL 3 support
@ -62,6 +63,7 @@ BuildRequires: libtool
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
Requires(pre): shadow-utils
%description
@ -88,16 +90,11 @@ sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%install
%make_install
find %{buildroot}%{_libdir} -type f -name \*.la -delete
rm %{buildroot}%{_sysusersdir}/tpm2-tss.conf
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/tpm2-tss.conf
%pre
getent group tss >/dev/null || groupadd -f -g 59 -r tss
if ! getent passwd tss >/dev/null ; then
if ! getent passwd 59 >/dev/null ; then
useradd -r -u 59 -g tss -d /dev/null -s /sbin/nologin -c "Account used for TPM access" tss
else
useradd -r -g tss -d /dev/null -s /sbin/nologin -c "Account used for TPM access" tss
fi
fi
%sysusers_create_compat %{SOURCE1}
exit 0
%ldconfig_scriptlets