]> granicus.if.org Git - icinga2/commitdiff
Improve TLS and cluster error messages
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Aug 2014 12:07:23 +0000 (14:07 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Aug 2014 12:07:23 +0000 (14:07 +0200)
refs #6066

lib/base/tlsstream.cpp
lib/remote/apilistener-sync.cpp

index 68d205f7cf5e4ce53c987d8c7b779a47853be458..04b8104492f828a3c4a0dae49232b09fe454948a 100644 (file)
@@ -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) {
@@ -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()));
                }
        }
 }
@@ -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()));
                        }
                }
 
@@ -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()));
                        }
                }
 
index 3210ab4a79c028a790c43c26035ae26f9fe4010f..62254c4b9c99501290f2bfd0cde631246f012c63 100644 (file)
@@ -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) << "\"";