Package init
This commit is contained in:
commit
1870e0d178
72
softhsm-2.3.0-reset-mutex-callbacks.patch
Normal file
72
softhsm-2.3.0-reset-mutex-callbacks.patch
Normal file
@ -0,0 +1,72 @@
|
||||
From 16f994e7944a917fa81c8db11c56c594f4e78b40 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bokovoy <abokovoy@redhat.com>
|
||||
Date: Tue, 31 Jul 2018 14:59:03 +0300
|
||||
Subject: [PATCH] Reset mutex callbacks to the default version when finished
|
||||
|
||||
If a PKCS11 API caller provided own mutex handling callbacks,
|
||||
we need to ensure they aren't used after C_Finalize is called
|
||||
and SoftHSM instance is recycled.
|
||||
|
||||
Inability to do so may lead to a situation where callbacks might
|
||||
be provided by a different dynamically loaded object which is removed
|
||||
after C_Finalize() call. Thus, callback pointers become invalid and
|
||||
calling them leads to crashes.
|
||||
|
||||
Fixes: https://github.com/opendnssec/SoftHSMv2/issues/408
|
||||
|
||||
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
|
||||
---
|
||||
src/lib/SoftHSM.cpp | 16 ++++++++++++----
|
||||
1 file changed, 12 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/lib/SoftHSM.cpp b/src/lib/SoftHSM.cpp
|
||||
index ee94d3f..e4cc044 100644
|
||||
--- a/src/lib/SoftHSM.cpp
|
||||
+++ b/src/lib/SoftHSM.cpp
|
||||
@@ -314,6 +314,15 @@ static CK_ATTRIBUTE bsAttribute(CK_ATTRIBUTE_TYPE type, const ByteString &value)
|
||||
/*****************************************************************************
|
||||
Implementation of SoftHSM class specific functions
|
||||
*****************************************************************************/
|
||||
+static void resetMutexFactoryCallbacks()
|
||||
+{
|
||||
+ // Reset MutexFactory callbacks to our versions
|
||||
+ MutexFactory::i()->setCreateMutex(OSCreateMutex);
|
||||
+ MutexFactory::i()->setDestroyMutex(OSDestroyMutex);
|
||||
+ MutexFactory::i()->setLockMutex(OSLockMutex);
|
||||
+ MutexFactory::i()->setUnlockMutex(OSUnlockMutex);
|
||||
+}
|
||||
+
|
||||
|
||||
// Return the one-and-only instance
|
||||
SoftHSM* SoftHSM::i()
|
||||
@@ -342,6 +351,7 @@ SoftHSM::SoftHSM()
|
||||
slotManager = NULL;
|
||||
sessionManager = NULL;
|
||||
handleManager = NULL;
|
||||
+ resetMutexFactoryCallbacks();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -352,6 +362,7 @@ SoftHSM::~SoftHSM()
|
||||
if (slotManager != NULL) delete slotManager;
|
||||
if (objectStore != NULL) delete objectStore;
|
||||
if (sessionObjectStore != NULL) delete sessionObjectStore;
|
||||
+ resetMutexFactoryCallbacks();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -402,10 +413,7 @@ CK_RV SoftHSM::C_Initialize(CK_VOID_PTR pInitArgs)
|
||||
if (args->flags & CKF_OS_LOCKING_OK)
|
||||
{
|
||||
// Use our own mutex functions.
|
||||
- MutexFactory::i()->setCreateMutex(OSCreateMutex);
|
||||
- MutexFactory::i()->setDestroyMutex(OSDestroyMutex);
|
||||
- MutexFactory::i()->setLockMutex(OSLockMutex);
|
||||
- MutexFactory::i()->setUnlockMutex(OSUnlockMutex);
|
||||
+ resetMutexFactoryCallbacks();
|
||||
MutexFactory::i()->enable();
|
||||
}
|
||||
else
|
||||
--
|
||||
2.17.1
|
||||
|
||||
BIN
softhsm-2.5.0.tar.gz
Normal file
BIN
softhsm-2.5.0.tar.gz
Normal file
Binary file not shown.
BIN
softhsm-2.5.0.tar.gz.sig
Normal file
BIN
softhsm-2.5.0.tar.gz.sig
Normal file
Binary file not shown.
104
softhsm.spec
Normal file
104
softhsm.spec
Normal file
@ -0,0 +1,104 @@
|
||||
Name: softhsm
|
||||
Version: 2.5.0
|
||||
Release: 1
|
||||
Summary: Software version of a PKCS#11 Hardware Security Module
|
||||
License: BSD
|
||||
Url: http://www.opendnssec.org/
|
||||
Source: http://dist.opendnssec.org/source/%{name}-%{version}.tar.gz
|
||||
Source1: http://dist.opendnssec.org/source/%{name}-%{version}.tar.gz.sig
|
||||
|
||||
BuildRequires: openssl-devel >= 1.0.1k-6, sqlite-devel >= 3.4.2, cppunit-devel
|
||||
BuildRequires: gcc-c++, pkgconfig, p11-kit-devel, nss-devel
|
||||
|
||||
Requires: shadow-utils, p11-kit, nss-tools, openssl-libs >= 1.0.1k-6
|
||||
|
||||
%description
|
||||
OpenDNSSEC is providing a software implementation of a generic
|
||||
cryptographic device with a PKCS#11 interface, the SoftHSM. SoftHSM is
|
||||
designed to meet the requirements of OpenDNSSEC, but can also work together
|
||||
with other cryptographic products because of the PKCS#11 interface.
|
||||
|
||||
%package devel
|
||||
Summary: Development package of softhsm that includes the header files
|
||||
Requires: %{name} = %{version}-%{release}, openssl-devel, sqlite-devel
|
||||
BuildRequires: autoconf, libtool, automake
|
||||
|
||||
%description devel
|
||||
The devel package contains the libsofthsm include files
|
||||
|
||||
%package help
|
||||
Summary: help package of softhsm that includes the man docs
|
||||
|
||||
%description help
|
||||
document files for %{name}
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version}
|
||||
|
||||
sed -i "s:full_libdir/softhsm:full_libdir:g" configure
|
||||
sed -i 's:^full_libdir=":#full_libdir=":g' configure.ac
|
||||
sed -i "s:libdir)/@PACKAGE@:libdir):" Makefile.in
|
||||
|
||||
%build
|
||||
%configure --libdir=%{_libdir}/pkcs11 --with-openssl=%{_prefix} --enable-ecc --disable-gost \
|
||||
--with-migrate --enable-visibility --with-p11-kit=%{_datadir}/p11-kit/modules/
|
||||
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%check
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make DESTDIR=%{buildroot} install
|
||||
mkdir -p %{buildroot}%{_includedir}/softhsm
|
||||
cp src/lib/*.h %{buildroot}%{_includedir}/softhsm
|
||||
mkdir -p %{buildroot}/%{_sharedstatedir}/softhsm/tokens
|
||||
mkdir -p %{buildroot}/%{_libdir}/softhsm/
|
||||
|
||||
cd %{buildroot}/%{_libdir}
|
||||
ln -sf ./pkcs11/libsofthsm2.so ./softhsm/libsofthsm.so
|
||||
ln -sf ./pkcs11/libsofthsm2.so %{buildroot}/%{_libdir}/libsofthsm2.so
|
||||
|
||||
rm %{buildroot}/%{_sysconfdir}/softhsm2.conf.sample
|
||||
rm -f %{buildroot}/%{_libdir}/pkcs11/*a
|
||||
|
||||
%files
|
||||
%config(noreplace) %{_sysconfdir}/softhsm2.conf
|
||||
%{_bindir}/*
|
||||
%dir %{_libdir}/softhsm
|
||||
%{_libdir}/softhsm/libsofthsm.so
|
||||
%{_libdir}/pkcs11/libsofthsm2.so
|
||||
%{_libdir}/libsofthsm2.so
|
||||
|
||||
%attr(0664,root,root) %{_datadir}/p11-kit/modules/softhsm2.module
|
||||
%attr(0750,ods,ods) %dir %{_sharedstatedir}/softhsm
|
||||
%attr(1770,ods,ods) %dir %{_sharedstatedir}/softhsm/tokens
|
||||
|
||||
|
||||
%doc LICENSE README.md NEWS
|
||||
|
||||
%files devel
|
||||
%attr(0755,root,root) %dir %{_includedir}/softhsm
|
||||
%{_includedir}/softhsm/*.h
|
||||
|
||||
%files help
|
||||
%{_mandir}/*/*
|
||||
|
||||
%pre
|
||||
getent group ods >/dev/null || groupadd -r ods
|
||||
getent passwd ods >/dev/null || \
|
||||
useradd -r -g ods -d %{_sharedstatedir}/softhsm -s /sbin/nologin \
|
||||
-c "softhsm private keys owner" ods
|
||||
exit 0
|
||||
|
||||
%post
|
||||
|
||||
%triggerpostun -- softhsm < 2.0.0
|
||||
if [ -f /var/softhsm/slot0.db ]; then
|
||||
runuser -g ods ods -c 'softhsm2-migrate --db /var/softhsm/slot0.db --pin 1234 --slot 0' || :
|
||||
fi
|
||||
|
||||
%changelog
|
||||
* Tue Sep 3 2019 openEuler Buildteam <buildteam@openeuler.org> 2.5.0-1
|
||||
- Package init
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user