Skip to content

Commit

Permalink
Improve TLS and cluster error messages
Browse files Browse the repository at this point in the history
refs #6066
  • Loading branch information
gunnarbeutner committed Aug 20, 2014
1 parent e1b8b05 commit 107a152
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/base/tlsstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const share
m_SSL = shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);

if (!m_SSL) {
msgbuf << "SSL_new() failed with code " << ERR_get_error() << ", \"" << ERR_error_string(ERR_get_error(), errbuf) << "\"";
msgbuf << "SSL_new() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
Log(LogCritical, "TlsStream", msgbuf.str());

BOOST_THROW_EXCEPTION(openssl_error()
<< boost::errinfo_api_function("SSL_new")
<< errinfo_openssl_error(ERR_get_error()));
<< errinfo_openssl_error(ERR_peek_error()));
}

if (!m_SSLIndexInitialized) {
Expand Down Expand Up @@ -126,12 +126,12 @@ void TlsStream::Handshake(void)
Close();
return;
default:
msgbuf << "SSL_do_handshake() failed with code " << ERR_get_error() << ", \"" << ERR_error_string(ERR_get_error(), errbuf) << "\"";
msgbuf << "SSL_do_handshake() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
Log(LogCritical, "TlsStream", msgbuf.str());

BOOST_THROW_EXCEPTION(openssl_error()
<< boost::errinfo_api_function("SSL_do_handshake")
<< errinfo_openssl_error(ERR_get_error()));
<< errinfo_openssl_error(ERR_peek_error()));
}
}
}
Expand Down Expand Up @@ -172,12 +172,12 @@ size_t TlsStream::Read(void *buffer, size_t count)
Close();
return count - left;
default:
msgbuf << "SSL_read() failed with code " << ERR_get_error() << ", \"" << ERR_error_string(ERR_get_error(), errbuf) << "\"";
msgbuf << "SSL_read() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
Log(LogCritical, "TlsStream", msgbuf.str());

BOOST_THROW_EXCEPTION(openssl_error()
<< boost::errinfo_api_function("SSL_read")
<< errinfo_openssl_error(ERR_get_error()));
<< errinfo_openssl_error(ERR_peek_error()));
}
}

Expand Down Expand Up @@ -220,12 +220,12 @@ void TlsStream::Write(const void *buffer, size_t count)
Close();
return;
default:
msgbuf << "SSL_write() failed with code " << ERR_get_error() << ", \"" << ERR_error_string(ERR_get_error(), errbuf) << "\"";
msgbuf << "SSL_write() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
Log(LogCritical, "TlsStream", msgbuf.str());

BOOST_THROW_EXCEPTION(openssl_error()
<< boost::errinfo_api_function("SSL_write")
<< errinfo_openssl_error(ERR_get_error()));
<< errinfo_openssl_error(ERR_peek_error()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/remote/apilistener-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio

void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
{
Log(LogInformation, "ApiListener", "Syncing zone: " + zone->GetName());

String newDir = Application::GetZonesDir() + "/" + zone->GetName();
String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();

Log(LogInformation, "ApiListener", "Copying zone configuration files from '" + newDir + "' to '" + oldDir + "'.");

if (!Utility::MkDir(oldDir, 0700)) {
std::ostringstream msgbuf;
msgbuf << "mkdir() for path '" << oldDir << "'failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
Expand Down

0 comments on commit 107a152

Please sign in to comment.