using logging level from config.xml

This commit is contained in:
Yuriy 2019-05-26 22:30:23 +03:00
parent 96e3574a06
commit 96c2bb383f
6 changed files with 9 additions and 17 deletions

View File

@ -40,7 +40,6 @@ MySQLHandler::MySQLHandler(IServer & server_, const Poco::Net::StreamSocket & so
, public_key(public_key)
, private_key(private_key)
{
log->setLevel("information");
server_capability_flags = CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | CLIENT_PLUGIN_AUTH | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | CLIENT_CONNECT_WITH_DB | CLIENT_DEPRECATE_EOF;
if (ssl_enabled)
server_capability_flags |= CLIENT_SSL;
@ -101,7 +100,7 @@ void MySQLHandler::run()
OK_Packet ok_packet(0, handshake_response.capability_flags, 0, 0, 0);
packet_sender->sendPacket(ok_packet, true);
for (;;)
while (true)
{
packet_sender->resetSequenceId();
String payload = packet_sender->receivePacketPayload();

View File

@ -89,8 +89,7 @@ void MySQLHandlerFactory::readRSAKeys()
SCOPE_EXIT(fclose(fp));
private_key.reset(PEM_read_RSAPrivateKey(fp, nullptr, nullptr, nullptr));
if (private_key.get() == nullptr)
if (!private_key)
throw Exception("Failed to read RSA private key from " + privateKeyFile + ". Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
}
}
@ -98,8 +97,8 @@ void MySQLHandlerFactory::readRSAKeys()
void MySQLHandlerFactory::generateRSAKeys()
{
LOG_INFO(log, "Generating new RSA key.");
RSAPtr rsa(RSA_new());
if (rsa == nullptr)
public_key.reset(RSA_new());
if (!public_key)
throw Exception("Failed to allocate RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
BIGNUM * e = BN_new();
@ -107,12 +106,10 @@ void MySQLHandlerFactory::generateRSAKeys()
throw Exception("Failed to allocate BIGNUM. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
SCOPE_EXIT(BN_free(e));
if (!BN_set_word(e, 65537) || !RSA_generate_key_ex(rsa.get(), 2048, e, nullptr))
if (!BN_set_word(e, 65537) || !RSA_generate_key_ex(public_key.get(), 2048, e, nullptr))
throw Exception("Failed to generate RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
public_key = std::move(rsa);
private_key.reset(RSAPrivateKey_dup(public_key.get()));
if (!private_key)
throw Exception("Failed to copy RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
}

View File

@ -14,7 +14,8 @@ private:
IServer & server;
Poco::Logger * log;
struct RSADeleter {
struct RSADeleter
{
void operator()(RSA * ptr) { RSA_free(ptr); }
};
using RSAPtr = std::unique_ptr<RSA, RSADeleter>;

View File

@ -6,9 +6,7 @@
namespace DB
{
/**
* Returns string with concatenation of the error strings for all errors that OpenSSL has recorded, emptying the error queue.
*/
/// Returns concatenation of error strings for all errors that OpenSSL has recorded, emptying the error queue.
String getOpenSSLErrors();
}

View File

@ -163,7 +163,6 @@ public:
, out(&out)
, log(&Poco::Logger::get(logger_name))
{
log->setLevel("information");
}
/// For writing.
@ -173,7 +172,6 @@ public:
, out(&out)
, log(&Poco::Logger::get(logger_name))
{
log->setLevel("information");
}
String receivePacketPayload()

View File

@ -26,8 +26,7 @@ void MySQLWireBlockOutputStream::writePrefix()
for (const ColumnWithTypeAndName & column : header.getColumnsWithTypeAndName())
{
ColumnDefinition column_definition(column.name, CharacterSet::binary, std::numeric_limits<uint32_t>::max(),
ColumnType::MYSQL_TYPE_STRING, 0, 0);
ColumnDefinition column_definition(column.name, CharacterSet::binary, 0, ColumnType::MYSQL_TYPE_STRING, 0, 0);
packet_sender->sendPacket(column_definition);
}