mirror of https://github.com/Icinga/icinga2.git
parent
2c7f440a73
commit
f7f8bd9b00
|
@ -95,7 +95,7 @@ void Application::Stop(void)
|
||||||
if (l_Restarting) {
|
if (l_Restarting) {
|
||||||
try {
|
try {
|
||||||
UpdatePidFile(GetPidPath(), m_ReloadProcess);
|
UpdatePidFile(GetPidPath(), m_ReloadProcess);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
/* abort restart */
|
/* abort restart */
|
||||||
Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
|
Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
|
||||||
return;
|
return;
|
||||||
|
@ -667,7 +667,7 @@ int Application::Run(void)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UpdatePidFile(GetPidPath());
|
UpdatePidFile(GetPidPath());
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "Application", "Cannot update PID file '" + GetPidPath() + "'. Aborting.");
|
Log(LogCritical, "Application", "Cannot update PID file '" + GetPidPath() + "'. Aborting.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return boost::lexical_cast<long>(val);
|
return boost::lexical_cast<long>(val);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "Can't convert '" << val << "' to an integer.";
|
msgbuf << "Can't convert '" << val << "' to an integer.";
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
|
||||||
|
@ -52,7 +52,7 @@ public:
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return boost::lexical_cast<double>(val);
|
return boost::lexical_cast<double>(val);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "Can't convert '" << val << "' to a floating point number.";
|
msgbuf << "Can't convert '" << val << "' to a floating point number.";
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
|
||||||
|
|
|
@ -128,7 +128,7 @@ LogSeverity Logger::GetMinSeverity(void) const
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ls = Logger::StringToSeverity(severity);
|
ls = Logger::StringToSeverity(severity);
|
||||||
} catch (std::exception&) { /* use the default level */ }
|
} catch (const std::exception&) { /* use the default level */ }
|
||||||
|
|
||||||
return ls;
|
return ls;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ String Socket::GetClientAddress(void)
|
||||||
String address;
|
String address;
|
||||||
try {
|
try {
|
||||||
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
|
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
/* already logged */
|
/* already logged */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ String Socket::GetPeerAddress(void)
|
||||||
String address;
|
String address;
|
||||||
try {
|
try {
|
||||||
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
|
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
/* already logged */
|
/* already logged */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ void StreamLogger::ProcessLogEntry(std::ostream& stream, bool tty, const LogEntr
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stream << Logger::SeverityToString(entry.Severity);
|
stream << Logger::SeverityToString(entry.Severity);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
/* bail early */
|
/* bail early */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,12 +115,12 @@ void TlsStream::Handshake(void)
|
||||||
case SSL_ERROR_WANT_READ:
|
case SSL_ERROR_WANT_READ:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(true, false);
|
m_Socket->Poll(true, false);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(false, true);
|
m_Socket->Poll(false, true);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
Close();
|
Close();
|
||||||
|
@ -161,12 +161,12 @@ size_t TlsStream::Read(void *buffer, size_t count)
|
||||||
case SSL_ERROR_WANT_READ:
|
case SSL_ERROR_WANT_READ:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(true, false);
|
m_Socket->Poll(true, false);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(false, true);
|
m_Socket->Poll(false, true);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
Close();
|
Close();
|
||||||
|
@ -209,12 +209,12 @@ void TlsStream::Write(const void *buffer, size_t count)
|
||||||
case SSL_ERROR_WANT_READ:
|
case SSL_ERROR_WANT_READ:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(true, false);
|
m_Socket->Poll(true, false);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(false, true);
|
m_Socket->Poll(false, true);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
Close();
|
Close();
|
||||||
|
@ -258,12 +258,12 @@ void TlsStream::Close(void)
|
||||||
case SSL_ERROR_WANT_READ:
|
case SSL_ERROR_WANT_READ:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(true, false);
|
m_Socket->Poll(true, false);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
try {
|
try {
|
||||||
m_Socket->Poll(false, true);
|
m_Socket->Poll(false, true);
|
||||||
} catch (std::exception&) {}
|
} catch (const std::exception&) {}
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
goto close_socket;
|
goto close_socket;
|
||||||
|
|
|
@ -155,7 +155,7 @@ bool ApiClient::ProcessMessage(void)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Function '" + method + "' does not exist."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Function '" + method + "' does not exist."));
|
||||||
|
|
||||||
resultMessage->Set("result", afunc->Invoke(origin, message->Get("params")));
|
resultMessage->Set("result", afunc->Invoke(origin, message->Get("params")));
|
||||||
} catch (std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
resultMessage->Set("error", DiagnosticInformation(ex));
|
resultMessage->Set("error", DiagnosticInformation(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ void ApiListener::SyncZoneDirs(void) const
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SyncZoneDir(zone);
|
SyncZoneDir(zone);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,14 +45,14 @@ void ApiListener::OnConfigLoaded(void)
|
||||||
shared_ptr<X509> cert = make_shared<X509>();
|
shared_ptr<X509> cert = make_shared<X509>();
|
||||||
try {
|
try {
|
||||||
cert = GetX509Certificate(GetCertPath());
|
cert = GetX509Certificate(GetCertPath());
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot get certificate from cert path: '" + GetCertPath() + "'.");
|
Log(LogCritical, "ApiListener", "Cannot get certificate from cert path: '" + GetCertPath() + "'.");
|
||||||
Application::Exit(EXIT_FAILURE);
|
Application::Exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SetIdentity(GetCertificateCN(cert));
|
SetIdentity(GetCertificateCN(cert));
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
|
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
|
||||||
Application::Exit(EXIT_FAILURE);
|
Application::Exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ void ApiListener::OnConfigLoaded(void)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot make SSL context for cert path: '" + GetCertPath() + "' key path: '" + GetKeyPath() + "' ca path: '" + GetCaPath() + "'.");
|
Log(LogCritical, "ApiListener", "Cannot make SSL context for cert path: '" + GetCertPath() + "' key path: '" + GetKeyPath() + "' ca path: '" + GetCaPath() + "'.");
|
||||||
Application::Exit(EXIT_FAILURE);
|
Application::Exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ void ApiListener::OnConfigLoaded(void)
|
||||||
if (!GetCrlPath().IsEmpty()) {
|
if (!GetCrlPath().IsEmpty()) {
|
||||||
try {
|
try {
|
||||||
AddCRLToSSLContext(m_SSLContext, GetCrlPath());
|
AddCRLToSSLContext(m_SSLContext, GetCrlPath());
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot add certificate revocation list to SSL context for crl path: '" + GetCrlPath() + "'.");
|
Log(LogCritical, "ApiListener", "Cannot add certificate revocation list to SSL context for crl path: '" + GetCrlPath() + "'.");
|
||||||
Application::Exit(EXIT_FAILURE);
|
Application::Exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
|
||||||
try {
|
try {
|
||||||
Socket::Ptr client = server->Accept();
|
Socket::Ptr client = server->Accept();
|
||||||
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleServer));
|
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleServer));
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
|
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
try {
|
try {
|
||||||
tlsStream = make_shared<TlsStream>(client, role, m_SSLContext);
|
tlsStream = make_shared<TlsStream>(client, role, m_SSLContext);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot create tls stream from client connection.");
|
Log(LogCritical, "ApiListener", "Cannot create tls stream from client connection.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tlsStream->Handshake();
|
tlsStream->Handshake();
|
||||||
} catch (std::exception) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Client TLS handshake failed.");
|
Log(LogCritical, "ApiListener", "Client TLS handshake failed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
|
||||||
|
|
||||||
try {
|
try {
|
||||||
identity = GetCertificateCN(cert);
|
identity = GetCertificateCN(cert);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
|
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue