mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 18:43:02 +01:00
remove redundant plugin reload on super server, update it only on classic after stateLock ast (#8393)
Co-authored-by: aleksey.mochalov <aleksey.mochalov@red-soft.ru>
This commit is contained in:
parent
a0aa292100
commit
03b615b8e1
@ -367,7 +367,7 @@ namespace Jrd {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fb_assert(tdbb);
|
fb_assert(tdbb);
|
||||||
lockAndReadHeader(tdbb, CRYPT_HDR_NOWAIT);
|
lockAndReadHeader(tdbb, CRYPT_HDR_NOWAIT | CRYPT_RELOAD_PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoManager::lockAndReadHeader(thread_db* tdbb, unsigned flags)
|
void CryptoManager::lockAndReadHeader(thread_db* tdbb, unsigned flags)
|
||||||
@ -407,9 +407,15 @@ namespace Jrd {
|
|||||||
crypt = hdr->hdr_flags & Ods::hdr_encrypted;
|
crypt = hdr->hdr_flags & Ods::hdr_encrypted;
|
||||||
process = hdr->hdr_flags & Ods::hdr_crypt_process;
|
process = hdr->hdr_flags & Ods::hdr_crypt_process;
|
||||||
|
|
||||||
|
if (flags & CRYPT_RELOAD_PLUGIN && cryptPlugin)
|
||||||
|
{
|
||||||
|
PluginManagerInterfacePtr()->releasePlugin(cryptPlugin);
|
||||||
|
cryptPlugin = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// tdbb w/o attachment comes when database is shutting down in the end of detachDatabase()
|
// tdbb w/o attachment comes when database is shutting down in the end of detachDatabase()
|
||||||
// the only needed here page is header, i.e. we can live w/o cryptPlugin
|
// the only needed here page is header, i.e. we can live w/o cryptPlugin
|
||||||
if ((crypt || process) && tdbb->getAttachment())
|
if ((crypt || process) && !cryptPlugin && tdbb->getAttachment())
|
||||||
{
|
{
|
||||||
ClumpletWriter hc(ClumpletWriter::UnTagged, hdr->hdr_page_size);
|
ClumpletWriter hc(ClumpletWriter::UnTagged, hdr->hdr_page_size);
|
||||||
hdr.getClumplets(hc);
|
hdr.getClumplets(hc);
|
||||||
@ -418,8 +424,6 @@ namespace Jrd {
|
|||||||
else
|
else
|
||||||
keyName = "";
|
keyName = "";
|
||||||
|
|
||||||
if (!cryptPlugin)
|
|
||||||
{
|
|
||||||
loadPlugin(tdbb, hdr->hdr_crypt_plugin);
|
loadPlugin(tdbb, hdr->hdr_crypt_plugin);
|
||||||
pluginName = hdr->hdr_crypt_plugin;
|
pluginName = hdr->hdr_crypt_plugin;
|
||||||
string valid;
|
string valid;
|
||||||
@ -433,42 +437,6 @@ namespace Jrd {
|
|||||||
else
|
else
|
||||||
hash = valid;
|
hash = valid;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
for (GetPlugins<IKeyHolderPlugin> keyControl(IPluginManager::TYPE_KEY_HOLDER, dbb.dbb_config);
|
|
||||||
keyControl.hasData(); keyControl.next())
|
|
||||||
{
|
|
||||||
// check does keyHolder want to provide a key for us
|
|
||||||
IKeyHolderPlugin* keyHolder = keyControl.plugin();
|
|
||||||
|
|
||||||
FbLocalStatus st;
|
|
||||||
int keyCallbackRc = keyHolder->keyCallback(&st, tdbb->getAttachment()->att_crypt_callback);
|
|
||||||
st.check();
|
|
||||||
if (!keyCallbackRc)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// validate a key
|
|
||||||
AutoPlugin<IDbCryptPlugin> crypt(checkFactory->makeInstance());
|
|
||||||
setDbInfo(crypt);
|
|
||||||
crypt->setKey(&st, 1, &keyHolder, keyName.c_str());
|
|
||||||
|
|
||||||
|
|
||||||
string valid;
|
|
||||||
calcValidation(valid, crypt);
|
|
||||||
if (hc.find(Ods::HDR_crypt_hash))
|
|
||||||
{
|
|
||||||
hc.getString(hash);
|
|
||||||
if (hash == valid)
|
|
||||||
{
|
|
||||||
// unload old plugin and set new one
|
|
||||||
PluginManagerInterfacePtr()->releasePlugin(cryptPlugin);
|
|
||||||
cryptPlugin = NULL;
|
|
||||||
cryptPlugin = crypt.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cryptPlugin && (flags & CRYPT_HDR_INIT))
|
if (cryptPlugin && (flags & CRYPT_HDR_INIT))
|
||||||
checkDigitalSignature(tdbb, hdr);
|
checkDigitalSignature(tdbb, hdr);
|
||||||
|
@ -364,6 +364,7 @@ private:
|
|||||||
void lockAndReadHeader(thread_db* tdbb, unsigned flags = 0);
|
void lockAndReadHeader(thread_db* tdbb, unsigned flags = 0);
|
||||||
static const unsigned CRYPT_HDR_INIT = 0x01;
|
static const unsigned CRYPT_HDR_INIT = 0x01;
|
||||||
static const unsigned CRYPT_HDR_NOWAIT = 0x02;
|
static const unsigned CRYPT_HDR_NOWAIT = 0x02;
|
||||||
|
static const unsigned CRYPT_RELOAD_PLUGIN = 0x04;
|
||||||
|
|
||||||
void addClumplet(Firebird::string& value, Firebird::ClumpletReader& block, UCHAR tag);
|
void addClumplet(Firebird::string& value, Firebird::ClumpletReader& block, UCHAR tag);
|
||||||
void calcDigitalSignature(thread_db* tdbb, Firebird::string& signature, const class Header& hdr);
|
void calcDigitalSignature(thread_db* tdbb, Firebird::string& signature, const class Header& hdr);
|
||||||
|
Loading…
Reference in New Issue
Block a user