Move common sanity check code to init/common
This commit is contained in:
1 parent
a67b54855b
commit
387c4cf588
3 files changed
+31
-26
No files matched your search
+2
-26
@@ -672,30 +672,6 @@ static void StartupNotify(const ArgsManager& args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Sanity checks
|
|
||||||
* Ensure that Bitcoin is running in a usable environment with all
|
|
||||||
* necessary library support.
|
|
||||||
*/
|
|
||||||
static bool InitSanityCheck()
|
|
||||||
{
|
|
||||||
if (!ECC_InitSanityCheck()) {
|
|
||||||
return InitError(Untranslated("Elliptic curve cryptography sanity check failure. Aborting."));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!glibcxx_sanity_test())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!Random_SanityCheck()) {
|
|
||||||
return InitError(Untranslated("OS cryptographic RNG sanity check failure. Aborting."));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ChronoSanityCheck()) {
|
|
||||||
return InitError(Untranslated("Clock epoch mismatch. Aborting."));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool AppInitServers(NodeContext& node)
|
static bool AppInitServers(NodeContext& node)
|
||||||
{
|
{
|
||||||
const ArgsManager& args = *Assert(node.args);
|
const ArgsManager& args = *Assert(node.args);
|
||||||
@@ -1147,9 +1123,9 @@ bool AppInitSanityChecks()
|
|||||||
|
|
||||||
init::SetGlobals();
|
init::SetGlobals();
|
||||||
|
|
||||||
// Sanity check
|
if (!init::SanityChecks()) {
|
||||||
if (!InitSanityCheck())
|
|
||||||
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
|
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
// Probe the data directory lock to give an early error message, if possible
|
// Probe the data directory lock to give an early error message, if possible
|
||||||
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
|
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
|
||||||
|
|||||||
@@ -2,11 +2,15 @@
|
|||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <compat/sanity.h>
|
||||||
#include <crypto/sha256.h>
|
#include <crypto/sha256.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
|
#include <node/ui_interface.h>
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
|
#include <util/time.h>
|
||||||
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -27,4 +31,24 @@ void UnsetGlobals()
|
|||||||
globalVerifyHandle.reset();
|
globalVerifyHandle.reset();
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SanityChecks()
|
||||||
|
{
|
||||||
|
if (!ECC_InitSanityCheck()) {
|
||||||
|
return InitError(Untranslated("Elliptic curve cryptography sanity check failure. Aborting."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!glibcxx_sanity_test())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!Random_SanityCheck()) {
|
||||||
|
return InitError(Untranslated("OS cryptographic RNG sanity check failure. Aborting."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ChronoSanityCheck()) {
|
||||||
|
return InitError(Untranslated("Clock epoch mismatch. Aborting."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} // namespace init
|
} // namespace init
|
||||||
@@ -11,6 +11,11 @@
|
|||||||
namespace init {
|
namespace init {
|
||||||
void SetGlobals();
|
void SetGlobals();
|
||||||
void UnsetGlobals();
|
void UnsetGlobals();
|
||||||
|
/**
|
||||||
|
* Ensure a usable environment with all
|
||||||
|
* necessary library support.
|
||||||
|
*/
|
||||||
|
bool SanityChecks();
|
||||||
} // namespace init
|
} // namespace init
|
||||||
|
|
||||||
#endif // BITCOIN_INIT_COMMON_H
|
#endif // BITCOIN_INIT_COMMON_H
|
||||||
Reference in new issue
Block a user