#include "SSDLSession.h"
#include <security_cdsa_utilities/KeySchema.h>
#include <security_cdsa_plugin/cssmplugin.h>
+#include <security_utilities/threading.h>
using namespace CssmClient;
using namespace SecurityServer;
mAllocator(session), mKeyHandle(keyHandle),
mClientSession(session.clientSession())
{
+ StLock<Mutex> _ (mMutex); // In the constructor??? Yes. Our handlers aren't thread safe in the slightest...
CssmKey::Header &header = ioKey.header();
if (inKeyAttr & CSSM_KEYATTR_PERMANENT)
{
mRecordType(recordType),
mClientSession(session.clientSession())
{
+ StLock<Mutex> _ (mMutex);
CssmKey::Header &header = ioKey.header();
memset(&header, 0, sizeof(header)); // Clear key header
SSKey::~SSKey()
{
+ StLock<Mutex> _(mMutex); // In the destructor too??? Yes. See SSCSPSession.cpp:354 for an explanation of this code's policy on threads.
if (mKeyHandle != noKey)
clientSession().releaseKey(mKeyHandle);
}
SSKey::free(const AccessCredentials *accessCred, CssmKey &ioKey,
CSSM_BOOL deleteKey)
{
+ StLock<Mutex> _(mMutex);
freeReferenceKey(mAllocator, ioKey);
if (deleteKey)
{
SecurityServer::ClientSession &
SSKey::clientSession()
{
+ StLock<Mutex> _(mMutex);
return mClientSession;
}
KeyHandle SSKey::optionalKeyHandle() const
{
+ StLock<Mutex> _(mMutex);
return mKeyHandle;
}
KeyHandle
SSKey::keyHandle()
{
+ StLock<Mutex> _(mMutex);
if (mKeyHandle == noKey)
{
// Deal with uninstantiated keys.
void
SSKey::getOwner(CSSM_ACL_OWNER_PROTOTYPE &owner, Allocator &allocator)
{
+ StLock<Mutex> _ (mMutex);
clientSession().getKeyOwner(keyHandle(), AclOwnerPrototype::overlay(owner),
allocator);
}
SSKey::changeOwner(const AccessCredentials &accessCred,
const AclOwnerPrototype &newOwner)
{
+ StLock<Mutex> _ (mMutex);
clientSession().changeKeyOwner(keyHandle(), accessCred, newOwner);
didChangeAcl();
}
SSKey::getAcl(const char *selectionTag, uint32 &numberOfAclInfos,
AclEntryInfo *&aclInfos, Allocator &allocator)
{
+ StLock<Mutex> _ (mMutex);
clientSession().getKeyAcl(keyHandle(), selectionTag, numberOfAclInfos,
aclInfos, allocator);
}
void
SSKey::changeAcl(const AccessCredentials &accessCred, const AclEdit &aclEdit)
{
+ StLock<Mutex> _ (mMutex);
clientSession().changeKeyAcl(keyHandle(), accessCred, aclEdit);
didChangeAcl();
}