Allow to start up with modified binary under gdb

This commit is contained in:
Alexey Milovidov 2021-02-26 20:15:11 +03:00
parent 9038fb3861
commit ac4d3b504e

View File

@ -82,6 +82,7 @@
#if defined(OS_LINUX)
# include <sys/mman.h>
# include <sys/ptrace.h>
# include <Common/hasLinuxCapability.h>
#endif
@ -479,6 +480,15 @@ int Server::main(const std::vector<std::string> & /*args*/)
LOG_INFO(log, "Calculated checksum of the binary: {}, integrity check passed.", calculated_binary_hash);
}
else
{
/// If program is run under debugger, ptrace will fail.
if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
{
/// Program is run under debugger. Modification of it's binary image is ok for breakpoints.
LOG_WARNING(log, "Server is run under debugger and its binary image is modified (most likely with breakpoints).",
calculated_binary_hash);
}
else
{
throw Exception(ErrorCodes::CORRUPTED_DATA,
"Calculated checksum of the ClickHouse binary ({0}) does not correspond"
@ -492,6 +502,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
, calculated_binary_hash, stored_binary_hash, executable_path);
}
}
}
else
executable_path = "/usr/bin/clickhouse"; /// It is used for information messages.