diff --git a/0001-swtpm_setup-Initialized-argv-to-NULL-Fedore-Rawhide.patch b/0001-swtpm_setup-Initialized-argv-to-NULL-Fedore-Rawhide.patch new file mode 100644 index 0000000000000000000000000000000000000000..efc0b2753344daf91da66603bbdf5f38f3c1623c --- /dev/null +++ b/0001-swtpm_setup-Initialized-argv-to-NULL-Fedore-Rawhide.patch @@ -0,0 +1,45 @@ +From 5b8c9d205a59932ce4e1894dbf09f5df4cfbb907 Mon Sep 17 00:00:00 2001 +From: Stefan Berger +Date: Thu, 10 Nov 2022 14:20:53 -0500 +Subject: [PATCH] swtpm_setup: Initialized **argv to NULL (Fedore Rawhide) + +gcc 12.2.1 on Fedora Rawhide emits this message: + +In file included from /usr/include/glib-2.0/glib.h:116, + from swtpm_setup.c:26: +In function 'g_autoptr_cleanup_generic_gfree', + inlined from 'get_swtpm_capabilities.constprop.0' at swtpm_setup.c:940:24: +/usr/include/glib-2.0/glib/glib-autocleanups.h:30:3: error: 'argv' may be used uninitialized [-Werror=maybe-uninitialized] + 30 | g_free (*pp); + | ^~~~~~~~~~~~ +swtpm_setup.c: In function 'get_swtpm_capabilities.constprop.0': +swtpm_setup.c:940:24: note: 'argv' was declared here + 940 | g_autofree gchar **argv; + | ^~~~ +cc1: all warnings being treated as errors + +This makes little sense since the variable is then first used like this: + + argv = concat_arrays(swtpm_prg_l, my_argv, FALSE); + +Signed-off-by: Stefan Berger +--- + src/swtpm_setup/swtpm_setup.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/swtpm_setup/swtpm_setup.c b/src/swtpm_setup/swtpm_setup.c +index 1b528c8..3570235 100644 +--- a/src/swtpm_setup/swtpm_setup.c ++++ b/src/swtpm_setup/swtpm_setup.c +@@ -937,7 +937,7 @@ static int get_swtpm_capabilities(gchar **swtpm_prg_l, gboolean is_tpm2, + gchar *my_argv[] = { "--print-capabilities", is_tpm2 ? "--tpm2" : NULL, NULL }; + g_autofree gchar *logop = NULL; + g_autoptr(GError) error = NULL; +- g_autofree gchar **argv; ++ g_autofree gchar **argv = NULL; + int exit_status = 0; + gboolean success; + int ret = 1; +-- +2.38.0 + diff --git a/swtpm.spec b/swtpm.spec new file mode 100644 index 0000000000000000000000000000000000000000..1d108e755d385ecc539755ac2e85a54ef05ab49a --- /dev/null +++ b/swtpm.spec @@ -0,0 +1,198 @@ +%define anolis_release 1 + +%bcond_without gnutls + +# Macros needed by SELinux +%global selinuxtype targeted +%global moduletype contrib +%global modulename swtpm + +Summary: TPM Emulator +Name: swtpm +Version: 0.8.0 +Release: %{anolis_release}%{?dist} +License: BSD +Url: http://github.com/stefanberger/swtpm +Source0: https://github.com/stefanberger/swtpm/archive/refs/tags/v%{version}.tar.gz + +Patch0001: 0001-swtpm_setup-Initialized-argv-to-NULL-Fedore-Rawhide.patch + +BuildRequires: make +BuildRequires: git-core +BuildRequires: automake +BuildRequires: autoconf +BuildRequires: libtool +BuildRequires: libtpms-devel >= 0.6.0 +BuildRequires: expect +BuildRequires: net-tools +BuildRequires: openssl-devel +BuildRequires: socat +BuildRequires: trousers >= 0.3.9 +BuildRequires: softhsm +BuildRequires: json-glib-devel +%if %{with gnutls} +BuildRequires: gnutls >= 3.4.0 +BuildRequires: gnutls-devel +BuildRequires: gnutls-utils +BuildRequires: libtasn1-devel +BuildRequires: libtasn1 +%endif +BuildRequires: selinux-policy-devel +BuildRequires: gcc +BuildRequires: libseccomp-devel +BuildRequires: tpm2-pkcs11 tpm2-pkcs11-tools tpm2-tools tpm2-abrmd +BuildRequires: python3-devel + +Requires: %{name}-libs = %{version}-%{release} +Requires: libtpms >= 0.6.0 +%{?selinux_requires} + +%description +TPM emulator built on libtpms providing TPM functionality for QEMU VMs + +%package libs +Summary: Private libraries for swtpm TPM emulators +License: BSD + +%description libs +A private library with callback functions for libtpms based swtpm TPM emulator + +%package devel +Summary: Include files for the TPM emulator's CUSE interface for usage by clients +License: BSD +Requires: %{name}-libs = %{version}-%{release} + +%description devel +Include files for the TPM emulator's CUSE interface. + +%package tools +Summary: Tools for the TPM emulator +License: BSD +Requires: swtpm = %{version}-%{release} +# trousers: for tss account +Requires: trousers >= 0.3.9 bash gnutls-utils + +%description tools +Tools for the TPM emulator from the swtpm package + +%package tools-pkcs11 +Summary: Tools for creating a local CA based on a TPM pkcs11 device +License: BSD +Requires: swtpm-tools = %{version}-%{release} +Requires: tpm2-pkcs11 tpm2-pkcs11-tools tpm2-tools tpm2-abrmd +Requires: expect gnutls-utils trousers >= 0.3.9 + +%description tools-pkcs11 +Tools for creating a local CA based on a pkcs11 device + +%package doc +Summary: Doc files for %{name} +Requires: %{name} = %{EVR} +BuildArch: noarch + +%description doc +Doc files for %{name} + +%prep +%autosetup -p1 + +%build + +NOCONFIGURE=1 ./autogen.sh +%configure \ +%if %{with gnutls} + --with-gnutls \ +%endif + --without-cuse + +%make_build + +%check +make %{?_smp_mflags} check VERBOSE=1 + +%install + +%make_install +rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/*.{a,la,so} + +%generate_compatibility_deps + +%post +for pp in /usr/share/selinux/packages/swtpm.pp \ + /usr/share/selinux/packages/swtpm_svirt.pp; do + %selinux_modules_install -s %{selinuxtype} ${pp} +done +restorecon %{_bindir}/swtpm + +%postun +if [ $1 -eq 0 ]; then + for p in swtpm swtpm_svirt; do + %selinux_modules_uninstall -s %{selinuxtype} $p + done +fi + +%posttrans +%selinux_relabel_post -s %{selinuxtype} + +%ldconfig_post libs +%ldconfig_postun libs + +%files +%license LICENSE +%{_bindir}/swtpm +%{_mandir}/man8/swtpm.8* +%{_datadir}/selinux/packages/swtpm.pp +%{_datadir}/selinux/packages/swtpm_svirt.pp + +%files libs +%license LICENSE + +%dir %{_libdir}/%{name} +%{_libdir}/%{name}/libswtpm_libtpms.so.0 +%{_libdir}/%{name}/libswtpm_libtpms.so.0.0.0 +%dir %{abidir} +%{abidir}/libswtpm_libtpms.dump + +%files devel +%dir %{_includedir}/%{name} +%{_includedir}/%{name}/*.h +%{_mandir}/man3/swtpm_ioctls.3* + +%files tools +%{_bindir}/swtpm_bios +%if %{with gnutls} +%{_bindir}/swtpm_cert +%endif +%{_bindir}/swtpm_setup +%{_bindir}/swtpm_ioctl +%{_bindir}/swtpm_localca +%{_mandir}/man5/swtpm-localca.conf.5* +%{_mandir}/man5/swtpm-localca.options.5* +%{_mandir}/man5/swtpm_setup.conf.5* +%{_mandir}/man8/swtpm_bios.8* +%{_mandir}/man8/swtpm_cert.8* +%{_mandir}/man8/swtpm_ioctl.8* +%{_mandir}/man8/swtpm-localca.8* +%{_mandir}/man8/swtpm_localca.8* +%{_mandir}/man8/swtpm_setup.8* +%{_mandir}/man8/swtpm_cuse.8* +%exclude %{_mandir}/man8/swtpm_cuse.8.gz +%config(noreplace) %{_sysconfdir}/swtpm_setup.conf +%config(noreplace) %{_sysconfdir}/swtpm-localca.options +%config(noreplace) %{_sysconfdir}/swtpm-localca.conf +%dir %{_datadir}/swtpm +%{_datadir}/swtpm/swtpm-localca +%{_datadir}/swtpm/swtpm-create-user-config-files +%attr( 750, tss, root) %{_localstatedir}/lib/swtpm-localca +%{abidir}/*-option.list + +%files tools-pkcs11 +%{_mandir}/man8/swtpm-create-tpmca.8* +%{_datadir}/swtpm/swtpm-create-tpmca + +%files doc +%doc README + +%changelog +* Sat Mar 18 2023 Chunmei Xu - 0.8.0-1 +- init from upstream diff --git a/v0.8.0.tar.gz b/v0.8.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ee5865e2c325ed35e333c654e93455e0f01798ad Binary files /dev/null and b/v0.8.0.tar.gz differ