From 07e8317a658a393e3518d08dca3296ce4bf62a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Hor=C3=A1=C4=8Dek?= Date: Tue, 4 Apr 2023 15:18:32 +0200 Subject: [PATCH] Use systemd-sysusers for user creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch taken from fedora/tpm2-tss commit 9608d38. Resolves: rhbz#2095479 Signed-off-by: Štěpán Horáček --- tpm2-tss-systemd-sysusers.conf | 2 ++ tpm2-tss.spec | 13 +++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 tpm2-tss-systemd-sysusers.conf diff --git a/tpm2-tss-systemd-sysusers.conf b/tpm2-tss-systemd-sysusers.conf new file mode 100644 index 0000000..bf66465 --- /dev/null +++ b/tpm2-tss-systemd-sysusers.conf @@ -0,0 +1,2 @@ +#Type Name ID GECOS Home directory Shell +u tss 59 "Account used for TPM access" - - diff --git a/tpm2-tss.spec b/tpm2-tss.spec index e35e1e0..a741f1f 100644 --- a/tpm2-tss.spec +++ b/tpm2-tss.spec @@ -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