Use std::shared_ptr instead of boost::shared_ptr

This commit is contained in:
Gunnar Beutner 2017-11-21 13:20:55 +01:00
parent 245feca0e7
commit 6d09efc907
34 changed files with 148 additions and 154 deletions

View File

@ -38,7 +38,7 @@ bool I2_EXPORT TlsStream::m_SSLIndexInitialized = false;
* @param role The role of the client. * @param role The role of the client.
* @param sslContext The SSL context for the client. * @param sslContext The SSL context for the client.
*/ */
TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext) TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const std::shared_ptr<SSL_CTX>& sslContext)
: SocketEvents(socket, this), m_Eof(false), m_HandshakeOK(false), m_VerifyOK(true), m_ErrorCode(0), : SocketEvents(socket, this), m_Eof(false), m_HandshakeOK(false), m_VerifyOK(true), m_ErrorCode(0),
m_ErrorOccurred(false), m_Socket(socket), m_Role(role), m_SendQ(new FIFO()), m_RecvQ(new FIFO()), m_ErrorOccurred(false), m_Socket(socket), m_Role(role), m_SendQ(new FIFO()), m_RecvQ(new FIFO()),
m_CurrentAction(TlsActionNone), m_Retry(false), m_Shutdown(false) m_CurrentAction(TlsActionNone), m_Retry(false), m_Shutdown(false)
@ -46,7 +46,7 @@ TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, Connecti
std::ostringstream msgbuf; std::ostringstream msgbuf;
char errbuf[120]; char errbuf[120];
m_SSL = boost::shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free); m_SSL = std::shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);
if (!m_SSL) { if (!m_SSL) {
msgbuf << "SSL_new() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\""; msgbuf << "SSL_new() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
@ -119,10 +119,10 @@ String TlsStream::GetVerifyError(void) const
* *
* @returns The X509 certificate. * @returns The X509 certificate.
*/ */
boost::shared_ptr<X509> TlsStream::GetClientCertificate(void) const std::shared_ptr<X509> TlsStream::GetClientCertificate(void) const
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);
return boost::shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter); return std::shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter);
} }
/** /**
@ -130,10 +130,10 @@ boost::shared_ptr<X509> TlsStream::GetClientCertificate(void) const
* *
* @returns The X509 certificate. * @returns The X509 certificate.
*/ */
boost::shared_ptr<X509> TlsStream::GetPeerCertificate(void) const std::shared_ptr<X509> TlsStream::GetPeerCertificate(void) const
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);
return boost::shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free); return std::shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
} }
void TlsStream::OnEvent(int revents) void TlsStream::OnEvent(int revents)

View File

@ -48,13 +48,13 @@ class I2_BASE_API TlsStream : public Stream, private SocketEvents
public: public:
DECLARE_PTR_TYPEDEFS(TlsStream); DECLARE_PTR_TYPEDEFS(TlsStream);
TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext = MakeSSLContext()); TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const std::shared_ptr<SSL_CTX>& sslContext = MakeSSLContext());
~TlsStream(void); ~TlsStream(void);
Socket::Ptr GetSocket(void) const; Socket::Ptr GetSocket(void) const;
boost::shared_ptr<X509> GetClientCertificate(void) const; std::shared_ptr<X509> GetClientCertificate(void) const;
boost::shared_ptr<X509> GetPeerCertificate(void) const; std::shared_ptr<X509> GetPeerCertificate(void) const;
void Handshake(void); void Handshake(void);
@ -74,7 +74,7 @@ public:
String GetVerifyError(void) const; String GetVerifyError(void) const;
private: private:
boost::shared_ptr<SSL> m_SSL; std::shared_ptr<SSL> m_SSL;
bool m_Eof; bool m_Eof;
mutable boost::mutex m_Mutex; mutable boost::mutex m_Mutex;
mutable boost::condition_variable m_CV; mutable boost::condition_variable m_CV;

View File

@ -81,13 +81,13 @@ void InitializeOpenSSL(void)
* @param cakey CA certificate chain file. * @param cakey CA certificate chain file.
* @returns An SSL context. * @returns An SSL context.
*/ */
boost::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey) std::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey)
{ {
char errbuf[120]; char errbuf[120];
InitializeOpenSSL(); InitializeOpenSSL();
boost::shared_ptr<SSL_CTX> sslContext = boost::shared_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_method()), SSL_CTX_free); std::shared_ptr<SSL_CTX> sslContext = std::shared_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_method()), SSL_CTX_free);
EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp384r1); EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp384r1);
@ -174,7 +174,7 @@ boost::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& pr
* @param context The ssl context. * @param context The ssl context.
* @param cipherList The ciper list. * @param cipherList The ciper list.
**/ **/
void SetCipherListToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& cipherList) void SetCipherListToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& cipherList)
{ {
char errbuf[256]; char errbuf[256];
@ -198,7 +198,7 @@ void SetCipherListToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const
* @param context The ssl context. * @param context The ssl context.
* @param tlsProtocolmin The minimum TLS protocol version. * @param tlsProtocolmin The minimum TLS protocol version.
*/ */
void SetTlsProtocolminToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin) void SetTlsProtocolminToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin)
{ {
long flags = SSL_CTX_get_options(context.get()); long flags = SSL_CTX_get_options(context.get());
@ -226,7 +226,7 @@ void SetTlsProtocolminToSSLContext(const boost::shared_ptr<SSL_CTX>& context, co
* @param context The SSL context. * @param context The SSL context.
* @param crlPath The path to the CRL file. * @param crlPath The path to the CRL file.
*/ */
void AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath) void AddCRLToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& crlPath)
{ {
char errbuf[120]; char errbuf[120];
X509_STORE *x509_store = SSL_CTX_get_cert_store(context.get()); X509_STORE *x509_store = SSL_CTX_get_cert_store(context.get());
@ -281,7 +281,7 @@ static String GetX509NameCN(X509_NAME *name)
* @param certificate The X509 certificate. * @param certificate The X509 certificate.
* @returns The common name. * @returns The common name.
*/ */
String GetCertificateCN(const boost::shared_ptr<X509>& certificate) String GetCertificateCN(const std::shared_ptr<X509>& certificate)
{ {
return GetX509NameCN(X509_get_subject_name(certificate.get())); return GetX509NameCN(X509_get_subject_name(certificate.get()));
} }
@ -292,7 +292,7 @@ String GetCertificateCN(const boost::shared_ptr<X509>& certificate)
* @param pemfile The filename. * @param pemfile The filename.
* @returns An X509 certificate. * @returns An X509 certificate.
*/ */
boost::shared_ptr<X509> GetX509Certificate(const String& pemfile) std::shared_ptr<X509> GetX509Certificate(const String& pemfile)
{ {
char errbuf[120]; char errbuf[120];
X509 *cert; X509 *cert;
@ -327,7 +327,7 @@ boost::shared_ptr<X509> GetX509Certificate(const String& pemfile)
BIO_free(fpcert); BIO_free(fpcert);
return boost::shared_ptr<X509>(cert, X509_free); return std::shared_ptr<X509>(cert, X509_free);
} }
int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile, const String& certfile, bool ca) int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile, const String& certfile, bool ca)
@ -402,7 +402,7 @@ int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile,
X509_NAME *subject = X509_NAME_new(); X509_NAME *subject = X509_NAME_new();
X509_NAME_add_entry_by_txt(subject, "CN", MBSTRING_ASC, (unsigned char *)cn.CStr(), -1, -1, 0); X509_NAME_add_entry_by_txt(subject, "CN", MBSTRING_ASC, (unsigned char *)cn.CStr(), -1, -1, 0);
boost::shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca); std::shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca);
X509_NAME_free(subject); X509_NAME_free(subject);
@ -491,7 +491,7 @@ int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile,
return 1; return 1;
} }
boost::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca) std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca)
{ {
X509 *cert = X509_new(); X509 *cert = X509_new();
X509_set_version(cert, 2); X509_set_version(cert, 2);
@ -568,7 +568,7 @@ boost::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NA
X509_sign(cert, cakey, EVP_sha256()); X509_sign(cert, cakey, EVP_sha256());
return boost::shared_ptr<X509>(cert, X509_free); return std::shared_ptr<X509>(cert, X509_free);
} }
String GetIcingaCADir(void) String GetIcingaCADir(void)
@ -576,7 +576,7 @@ String GetIcingaCADir(void)
return Application::GetLocalStateDir() + "/lib/icinga2/ca"; return Application::GetLocalStateDir() + "/lib/icinga2/ca";
} }
boost::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject) std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
{ {
char errbuf[120]; char errbuf[120];
@ -589,7 +589,7 @@ boost::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
if (!cakeybio) { if (!cakeybio) {
Log(LogCritical, "SSL") Log(LogCritical, "SSL")
<< "Could not open CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\""; << "Could not open CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
return boost::shared_ptr<X509>(); return std::shared_ptr<X509>();
} }
EVP_PKEY *privkey = PEM_read_bio_PrivateKey(cakeybio, NULL, NULL, NULL); EVP_PKEY *privkey = PEM_read_bio_PrivateKey(cakeybio, NULL, NULL, NULL);
@ -597,25 +597,25 @@ boost::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
if (!privkey) { if (!privkey) {
Log(LogCritical, "SSL") Log(LogCritical, "SSL")
<< "Could not read private key from CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\""; << "Could not read private key from CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
return boost::shared_ptr<X509>(); return std::shared_ptr<X509>();
} }
BIO_free(cakeybio); BIO_free(cakeybio);
String cacertfile = cadir + "/ca.crt"; String cacertfile = cadir + "/ca.crt";
boost::shared_ptr<X509> cacert = GetX509Certificate(cacertfile); std::shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
return CreateCert(pubkey, subject, X509_get_subject_name(cacert.get()), privkey, false); return CreateCert(pubkey, subject, X509_get_subject_name(cacert.get()), privkey, false);
} }
boost::shared_ptr<X509> CreateCertIcingaCA(const boost::shared_ptr<X509>& cert) std::shared_ptr<X509> CreateCertIcingaCA(const std::shared_ptr<X509>& cert)
{ {
boost::shared_ptr<EVP_PKEY> pkey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free); std::shared_ptr<EVP_PKEY> pkey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
return CreateCertIcingaCA(pkey.get(), X509_get_subject_name(cert.get())); return CreateCertIcingaCA(pkey.get(), X509_get_subject_name(cert.get()));
} }
String CertificateToString(const boost::shared_ptr<X509>& cert) String CertificateToString(const std::shared_ptr<X509>& cert)
{ {
BIO *mem = BIO_new(BIO_s_mem()); BIO *mem = BIO_new(BIO_s_mem());
PEM_write_bio_X509(mem, cert.get()); PEM_write_bio_X509(mem, cert.get());
@ -630,7 +630,7 @@ String CertificateToString(const boost::shared_ptr<X509>& cert)
return result; return result;
} }
boost::shared_ptr<X509> StringToCertificate(const String& cert) std::shared_ptr<X509> StringToCertificate(const String& cert)
{ {
BIO *bio = BIO_new(BIO_s_mem()); BIO *bio = BIO_new(BIO_s_mem());
BIO_write(bio, (const void *)cert.CStr(), cert.GetLength()); BIO_write(bio, (const void *)cert.CStr(), cert.GetLength());
@ -642,7 +642,7 @@ boost::shared_ptr<X509> StringToCertificate(const String& cert)
if (!rawCert) if (!rawCert)
BOOST_THROW_EXCEPTION(std::invalid_argument("The specified X509 certificate is invalid.")); BOOST_THROW_EXCEPTION(std::invalid_argument("The specified X509 certificate is invalid."));
return boost::shared_ptr<X509>(rawCert, X509_free); return std::shared_ptr<X509>(rawCert, X509_free);
} }
String PBKDF2_SHA1(const String& password, const String& salt, int iterations) String PBKDF2_SHA1(const String& password, const String& salt, int iterations)
@ -762,7 +762,7 @@ String RandomString(int length)
return result; return result;
} }
bool VerifyCertificate(const boost::shared_ptr<X509>& caCertificate, const boost::shared_ptr<X509>& certificate) bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate)
{ {
X509_STORE *store = X509_STORE_new(); X509_STORE *store = X509_STORE_new();

View File

@ -31,31 +31,30 @@
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/exception/info.hpp> #include <boost/exception/info.hpp>
namespace icinga namespace icinga
{ {
void I2_BASE_API InitializeOpenSSL(void); void I2_BASE_API InitializeOpenSSL(void);
boost::shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String()); std::shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String());
void I2_BASE_API AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath); void I2_BASE_API AddCRLToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& crlPath);
void I2_BASE_API SetCipherListToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& cipherList); void I2_BASE_API SetCipherListToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& cipherList);
void I2_BASE_API SetTlsProtocolminToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin); void I2_BASE_API SetTlsProtocolminToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin);
String I2_BASE_API GetCertificateCN(const boost::shared_ptr<X509>& certificate); String I2_BASE_API GetCertificateCN(const std::shared_ptr<X509>& certificate);
boost::shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile); std::shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile);
int I2_BASE_API MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile = String(), const String& certfile = String(), bool ca = false); int I2_BASE_API MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile = String(), const String& certfile = String(), bool ca = false);
boost::shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca); std::shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca);
String I2_BASE_API GetIcingaCADir(void); String I2_BASE_API GetIcingaCADir(void);
String I2_BASE_API CertificateToString(const boost::shared_ptr<X509>& cert); String I2_BASE_API CertificateToString(const std::shared_ptr<X509>& cert);
boost::shared_ptr<X509> I2_BASE_API StringToCertificate(const String& cert); std::shared_ptr<X509> I2_BASE_API StringToCertificate(const String& cert);
boost::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject); std::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
boost::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(const boost::shared_ptr<X509>& cert); std::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(const std::shared_ptr<X509>& cert);
String I2_BASE_API PBKDF2_SHA1(const String& password, const String& salt, int iterations); String I2_BASE_API PBKDF2_SHA1(const String& password, const String& salt, int iterations);
String I2_BASE_API SHA1(const String& s, bool binary = false); String I2_BASE_API SHA1(const String& s, bool binary = false);
String I2_BASE_API SHA256(const String& s); String I2_BASE_API SHA256(const String& s);
String I2_BASE_API RandomString(int length); String I2_BASE_API RandomString(int length);
bool I2_BASE_API VerifyCertificate(const boost::shared_ptr<X509>& caCertificate, const boost::shared_ptr<X509>& certificate); bool I2_BASE_API VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate);
class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { }; class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { };

View File

@ -69,14 +69,14 @@ int CASignCommand::Run(const boost::program_options::variables_map& vm, const st
String certRequestText = request->Get("cert_request"); String certRequestText = request->Get("cert_request");
boost::shared_ptr<X509> certRequest = StringToCertificate(certRequestText); std::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
if (!certRequest) { if (!certRequest) {
Log(LogCritical, "cli", "Certificate request is invalid. Could not parse X.509 certificate for the 'cert_request' attribute."); Log(LogCritical, "cli", "Certificate request is invalid. Could not parse X.509 certificate for the 'cert_request' attribute.");
return 1; return 1;
} }
boost::shared_ptr<X509> certResponse = CreateCertIcingaCA(certRequest); std::shared_ptr<X509> certResponse = CreateCertIcingaCA(certRequest);
BIO *out = BIO_new(BIO_s_mem()); BIO *out = BIO_new(BIO_s_mem());
X509_NAME_print_ex(out, X509_get_subject_name(certRequest.get()), 0, XN_FLAG_ONELINE & ~ASN1_STRFLGS_ESC_MSB); X509_NAME_print_ex(out, X509_get_subject_name(certRequest.get()), 0, XN_FLAG_ONELINE & ~ASN1_STRFLGS_ESC_MSB);

View File

@ -291,7 +291,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
return 1; return 1;
} }
boost::shared_ptr<X509> trustedcert = GetX509Certificate(vm["trustedcert"].as<std::string>()); std::shared_ptr<X509> trustedcert = GetX509Certificate(vm["trustedcert"].as<std::string>());
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Verifying trusted certificate file '" << vm["trustedcert"].as<std::string>() << "'."; << "Verifying trusted certificate file '" << vm["trustedcert"].as<std::string>() << "'.";

View File

@ -303,7 +303,7 @@ wizard_endpoint_loop_start:
<< "' on file '" << nodeKey << "'. Verify it yourself!"; << "' on file '" << nodeKey << "'. Verify it yourself!";
} }
boost::shared_ptr<X509> trustedParentCert; std::shared_ptr<X509> trustedParentCert;
/* Check whether we should connect to the parent node and present its trusted certificate. */ /* Check whether we should connect to the parent node and present its trusted certificate. */
if (connectToParent) { if (connectToParent) {

View File

@ -85,7 +85,7 @@ int PKISaveCertCommand::Run(const boost::program_options::variables_map& vm, con
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Retrieving X.509 certificate for '" << host << ":" << port << "'."; << "Retrieving X.509 certificate for '" << host << ":" << port << "'.";
boost::shared_ptr<X509> cert = PkiUtility::FetchCert(host, port); std::shared_ptr<X509> cert = PkiUtility::FetchCert(host, port);
if (!cert) { if (!cert) {
Log(LogCritical, "cli", "Failed to fetch certificate from host."); Log(LogCritical, "cli", "Failed to fetch certificate from host.");

View File

@ -26,8 +26,8 @@ using namespace icinga;
ApplyRule::RuleMap ApplyRule::m_Rules; ApplyRule::RuleMap ApplyRule::m_Rules;
ApplyRule::TypeMap ApplyRule::m_Types; ApplyRule::TypeMap ApplyRule::m_Types;
ApplyRule::ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression, ApplyRule::ApplyRule(const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope) bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
: m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar), : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar),
m_FVVar(fvvar), m_FTerm(fterm), m_IgnoreOnError(ignoreOnError), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false) m_FVVar(fvvar), m_FTerm(fterm), m_IgnoreOnError(ignoreOnError), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false)
@ -43,12 +43,12 @@ String ApplyRule::GetName(void) const
return m_Name; return m_Name;
} }
boost::shared_ptr<Expression> ApplyRule::GetExpression(void) const std::shared_ptr<Expression> ApplyRule::GetExpression(void) const
{ {
return m_Expression; return m_Expression;
} }
boost::shared_ptr<Expression> ApplyRule::GetFilter(void) const std::shared_ptr<Expression> ApplyRule::GetFilter(void) const
{ {
return m_Filter; return m_Filter;
} }
@ -68,7 +68,7 @@ String ApplyRule::GetFVVar(void) const
return m_FVVar; return m_FVVar;
} }
boost::shared_ptr<Expression> ApplyRule::GetFTerm(void) const std::shared_ptr<Expression> ApplyRule::GetFTerm(void) const
{ {
return m_FTerm; return m_FTerm;
} }
@ -89,8 +89,8 @@ Dictionary::Ptr ApplyRule::GetScope(void) const
} }
void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name, void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const std::shared_ptr<Expression>& expression, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
const String& fvvar, const boost::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope) const String& fvvar, const std::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
{ {
m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope)); m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope));
} }

View File

@ -38,12 +38,12 @@ public:
String GetTargetType(void) const; String GetTargetType(void) const;
String GetName(void) const; String GetName(void) const;
boost::shared_ptr<Expression> GetExpression(void) const; std::shared_ptr<Expression> GetExpression(void) const;
boost::shared_ptr<Expression> GetFilter(void) const; std::shared_ptr<Expression> GetFilter(void) const;
String GetPackage(void) const; String GetPackage(void) const;
String GetFKVar(void) const; String GetFKVar(void) const;
String GetFVVar(void) const; String GetFVVar(void) const;
boost::shared_ptr<Expression> GetFTerm(void) const; std::shared_ptr<Expression> GetFTerm(void) const;
bool GetIgnoreOnError(void) const; bool GetIgnoreOnError(void) const;
DebugInfo GetDebugInfo(void) const; DebugInfo GetDebugInfo(void) const;
Dictionary::Ptr GetScope(void) const; Dictionary::Ptr GetScope(void) const;
@ -52,8 +52,8 @@ public:
bool EvaluateFilter(ScriptFrame& frame) const; bool EvaluateFilter(ScriptFrame& frame) const;
static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression, static void AddRule(const String& sourceType, const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
static std::vector<ApplyRule>& GetRules(const String& type); static std::vector<ApplyRule>& GetRules(const String& type);
@ -67,12 +67,12 @@ public:
private: private:
String m_TargetType; String m_TargetType;
String m_Name; String m_Name;
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
boost::shared_ptr<Expression> m_Filter; std::shared_ptr<Expression> m_Filter;
String m_Package; String m_Package;
String m_FKVar; String m_FKVar;
String m_FVVar; String m_FVVar;
boost::shared_ptr<Expression> m_FTerm; std::shared_ptr<Expression> m_FTerm;
bool m_IgnoreOnError; bool m_IgnoreOnError;
DebugInfo m_DebugInfo; DebugInfo m_DebugInfo;
Dictionary::Ptr m_Scope; Dictionary::Ptr m_Scope;
@ -81,8 +81,8 @@ private:
static TypeMap m_Types; static TypeMap m_Types;
static RuleMap m_Rules; static RuleMap m_Rules;
ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression, ApplyRule(const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
}; };

View File

@ -128,7 +128,7 @@ public:
static bool HasZoneConfigAuthority(const String& zoneName); static bool HasZoneConfigAuthority(const String& zoneName);
private: private:
std::promise<boost::shared_ptr<Expression> > m_Promise; std::promise<std::shared_ptr<Expression> > m_Promise;
String m_Path; String m_Path;
std::istream *m_Input; std::istream *m_Input;

View File

@ -60,8 +60,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, run_with_activation_context, &ConfigItem::R
* @param debuginfo Debug information. * @param debuginfo Debug information.
*/ */
ConfigItem::ConfigItem(const Type::Ptr& type, const String& name, ConfigItem::ConfigItem(const Type::Ptr& type, const String& name,
bool abstract, const boost::shared_ptr<Expression>& exprl, bool abstract, const std::shared_ptr<Expression>& exprl,
const boost::shared_ptr<Expression>& filter, bool defaultTmpl, bool ignoreOnError, const std::shared_ptr<Expression>& filter, bool defaultTmpl, bool ignoreOnError,
const DebugInfo& debuginfo, const Dictionary::Ptr& scope, const DebugInfo& debuginfo, const Dictionary::Ptr& scope,
const String& zone, const String& package) const String& zone, const String& package)
: m_Type(type), m_Name(name), m_Abstract(abstract), : m_Type(type), m_Name(name), m_Abstract(abstract),
@ -137,7 +137,7 @@ ConfigObject::Ptr ConfigItem::GetObject(void) const
* *
* @returns The expression list. * @returns The expression list.
*/ */
boost::shared_ptr<Expression> ConfigItem::GetExpression(void) const std::shared_ptr<Expression> ConfigItem::GetExpression(void) const
{ {
return m_Expression; return m_Expression;
} }
@ -147,7 +147,7 @@ boost::shared_ptr<Expression> ConfigItem::GetExpression(void) const
* *
* @returns The filter expression. * @returns The filter expression.
*/ */
boost::shared_ptr<Expression> ConfigItem::GetFilter(void) const std::shared_ptr<Expression> ConfigItem::GetFilter(void) const
{ {
return m_Filter; return m_Filter;
} }

View File

@ -41,8 +41,8 @@ public:
DECLARE_PTR_TYPEDEFS(ConfigItem); DECLARE_PTR_TYPEDEFS(ConfigItem);
ConfigItem(const Type::Ptr& type, const String& name, bool abstract, ConfigItem(const Type::Ptr& type, const String& name, bool abstract,
const boost::shared_ptr<Expression>& exprl, const std::shared_ptr<Expression>& exprl,
const boost::shared_ptr<Expression>& filter, const std::shared_ptr<Expression>& filter,
bool defaultTmpl, bool ignoreOnError, const DebugInfo& debuginfo, bool defaultTmpl, bool ignoreOnError, const DebugInfo& debuginfo,
const Dictionary::Ptr& scope, const String& zone, const Dictionary::Ptr& scope, const String& zone,
const String& package); const String& package);
@ -55,8 +55,8 @@ public:
std::vector<ConfigItem::Ptr> GetParents(void) const; std::vector<ConfigItem::Ptr> GetParents(void) const;
boost::shared_ptr<Expression> GetExpression(void) const; std::shared_ptr<Expression> GetExpression(void) const;
boost::shared_ptr<Expression> GetFilter(void) const; std::shared_ptr<Expression> GetFilter(void) const;
void Register(void); void Register(void);
void Unregister(void); void Unregister(void);
@ -84,8 +84,8 @@ private:
String m_Name; /**< The name. */ String m_Name; /**< The name. */
bool m_Abstract; /**< Whether this is a template. */ bool m_Abstract; /**< Whether this is a template. */
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
boost::shared_ptr<Expression> m_Filter; std::shared_ptr<Expression> m_Filter;
bool m_DefaultTmpl; bool m_DefaultTmpl;
bool m_IgnoreOnError; bool m_IgnoreOnError;
DebugInfo m_DebugInfo; /**< Debug information. */ DebugInfo m_DebugInfo; /**< Debug information. */

View File

@ -20,7 +20,6 @@
#include "config/configitembuilder.hpp" #include "config/configitembuilder.hpp"
#include "base/configtype.hpp" #include "base/configtype.hpp"
#include <sstream> #include <sstream>
#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga; using namespace icinga;
@ -74,7 +73,7 @@ void ConfigItemBuilder::AddExpression(Expression *expr)
m_Expressions.push_back(expr); m_Expressions.push_back(expr);
} }
void ConfigItemBuilder::SetFilter(const boost::shared_ptr<Expression>& filter) void ConfigItemBuilder::SetFilter(const std::shared_ptr<Expression>& filter)
{ {
m_Filter = filter; m_Filter = filter;
} }
@ -138,7 +137,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
} }
#endif /* I2_DEBUG */ #endif /* I2_DEBUG */
boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo); std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(exprs, m_DebugInfo);
exprl->MakeInline(); exprl->MakeInline();
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter, return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,

View File

@ -52,7 +52,7 @@ public:
void SetIgnoreOnError(bool ignoreOnError); void SetIgnoreOnError(bool ignoreOnError);
void AddExpression(Expression *expr); void AddExpression(Expression *expr);
void SetFilter(const boost::shared_ptr<Expression>& filter); void SetFilter(const std::shared_ptr<Expression>& filter);
ConfigItem::Ptr Compile(void); ConfigItem::Ptr Compile(void);
@ -61,7 +61,7 @@ private:
String m_Name; /**< The name. */ String m_Name; /**< The name. */
bool m_Abstract; /**< Whether the item is abstract. */ bool m_Abstract; /**< Whether the item is abstract. */
std::vector<Expression *> m_Expressions; /**< Expressions for this item. */ std::vector<Expression *> m_Expressions; /**< Expressions for this item. */
boost::shared_ptr<Expression> m_Filter; /**< Filter expression. */ std::shared_ptr<Expression> m_Filter; /**< Filter expression. */
DebugInfo m_DebugInfo; /**< Debug information. */ DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */ Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */ String m_Zone; /**< The zone. */

View File

@ -216,7 +216,7 @@ I2_CONFIG_API Expression *MakeIndexer(ScopeSpecifier scopeSpec, const String& in
class I2_CONFIG_API OwnedExpression : public Expression class I2_CONFIG_API OwnedExpression : public Expression
{ {
public: public:
OwnedExpression(const boost::shared_ptr<Expression>& expression) OwnedExpression(const std::shared_ptr<Expression>& expression)
: m_Expression(expression) : m_Expression(expression)
{ } { }
@ -232,7 +232,7 @@ protected:
} }
private: private:
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
}; };
class I2_CONFIG_API LiteralExpression : public Expression class I2_CONFIG_API LiteralExpression : public Expression
@ -837,7 +837,7 @@ private:
String m_Name; String m_Name;
std::vector<String> m_Args; std::vector<String> m_Args;
std::map<String, Expression *> *m_ClosedVars; std::map<String, Expression *> *m_ClosedVars;
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
}; };
class I2_CONFIG_API ApplyExpression : public DebuggableExpression class I2_CONFIG_API ApplyExpression : public DebuggableExpression
@ -874,14 +874,14 @@ private:
String m_Type; String m_Type;
String m_Target; String m_Target;
Expression *m_Name; Expression *m_Name;
boost::shared_ptr<Expression> m_Filter; std::shared_ptr<Expression> m_Filter;
String m_Package; String m_Package;
String m_FKVar; String m_FKVar;
String m_FVVar; String m_FVVar;
boost::shared_ptr<Expression> m_FTerm; std::shared_ptr<Expression> m_FTerm;
bool m_IgnoreOnError; bool m_IgnoreOnError;
std::map<String, Expression *> *m_ClosedVars; std::map<String, Expression *> *m_ClosedVars;
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
}; };
class I2_CONFIG_API ObjectExpression : public DebuggableExpression class I2_CONFIG_API ObjectExpression : public DebuggableExpression
@ -916,13 +916,13 @@ private:
bool m_Abstract; bool m_Abstract;
Expression *m_Type; Expression *m_Type;
Expression *m_Name; Expression *m_Name;
boost::shared_ptr<Expression> m_Filter; std::shared_ptr<Expression> m_Filter;
String m_Zone; String m_Zone;
String m_Package; String m_Package;
bool m_DefaultTmpl; bool m_DefaultTmpl;
bool m_IgnoreOnError; bool m_IgnoreOnError;
std::map<String, Expression *> *m_ClosedVars; std::map<String, Expression *> *m_ClosedVars;
boost::shared_ptr<Expression> m_Expression; std::shared_ptr<Expression> m_Expression;
}; };
class I2_CONFIG_API ForExpression : public DebuggableExpression class I2_CONFIG_API ForExpression : public DebuggableExpression

View File

@ -33,7 +33,6 @@
#include "base/exception.hpp" #include "base/exception.hpp"
#include "base/convert.hpp" #include "base/convert.hpp"
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
#include <boost/smart_ptr/make_shared.hpp>
#include <map> #include <map>
#include <vector> #include <vector>
@ -110,7 +109,7 @@ public:
} }
static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& argNames, static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& argNames,
std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression) std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression)
{ {
auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars); auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars);
@ -132,9 +131,9 @@ public:
return new Function(name, wrapper, argNames); return new Function(name, wrapper, argNames);
} }
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter, static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const std::shared_ptr<Expression>& filter,
const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
bool ignoreOnError, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo()) bool ignoreOnError, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{ {
ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar, ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars)); fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars));
@ -142,8 +141,8 @@ public:
return Empty; return Empty;
} }
static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const boost::shared_ptr<Expression>& filter, static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter,
const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo()) const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{ {
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo); ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);

View File

@ -29,7 +29,7 @@
namespace icinga namespace icinga
{ {
typedef boost::shared_ptr<MYSQL_RES> IdoMysqlResult; typedef std::shared_ptr<MYSQL_RES> IdoMysqlResult;
typedef std::function<void (const IdoMysqlResult&)> IdoAsyncCallback; typedef std::function<void (const IdoMysqlResult&)> IdoAsyncCallback;

View File

@ -29,7 +29,7 @@
namespace icinga namespace icinga
{ {
typedef boost::shared_ptr<PGresult> IdoPgsqlResult; typedef std::shared_ptr<PGresult> IdoPgsqlResult;
/** /**
* An IDO pgSQL database connection. * An IDO pgSQL database connection.

View File

@ -528,7 +528,7 @@ Stream::Ptr ElasticsearchWriter::Connect(void)
} }
if (GetEnableTls()) { if (GetEnableTls()) {
boost::shared_ptr<SSL_CTX> sslContext; std::shared_ptr<SSL_CTX> sslContext;
try { try {
sslContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath()); sslContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());

View File

@ -150,7 +150,7 @@ Stream::Ptr InfluxdbWriter::Connect()
} }
if (GetSslEnable()) { if (GetSslEnable()) {
boost::shared_ptr<SSL_CTX> sslContext; std::shared_ptr<SSL_CTX> sslContext;
try { try {
sslContext = MakeSSLContext(GetSslCert(), GetSslKey(), GetSslCaCert()); sslContext = MakeSSLContext(GetSslCert(), GetSslKey(), GetSslCaCert());
} catch (const std::exception& ex) { } catch (const std::exception& ex) {

View File

@ -46,7 +46,7 @@ void ApiClient::GetTypes(const TypesCompletionCallback& callback) const
url->SetPath(path); url->SetPath(path);
try { try {
boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest(); std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET"; req->RequestMethod = "GET";
req->RequestUrl = url; req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password)); req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
@ -136,7 +136,7 @@ void ApiClient::GetObjects(const String& pluralType, const ObjectsCompletionCall
url->SetQuery(params); url->SetQuery(params);
try { try {
boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest(); std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET"; req->RequestMethod = "GET";
req->RequestUrl = url; req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password)); req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
@ -250,7 +250,7 @@ void ApiClient::ExecuteScript(const String& session, const String& command, bool
url->SetQuery(params); url->SetQuery(params);
try { try {
boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest(); std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "POST"; req->RequestMethod = "POST";
req->RequestUrl = url; req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password)); req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
@ -334,7 +334,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command,
url->SetQuery(params); url->SetQuery(params);
try { try {
boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest(); std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "POST"; req->RequestMethod = "POST";
req->RequestUrl = url; req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password)); req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));

View File

@ -128,7 +128,7 @@ void ApiListener::OnConfigLoaded(void)
} }
/* set up SSL context */ /* set up SSL context */
boost::shared_ptr<X509> cert; std::shared_ptr<X509> cert;
try { try {
cert = GetX509Certificate(defaultCertPath); cert = GetX509Certificate(defaultCertPath);
} catch (const std::exception&) { } catch (const std::exception&) {
@ -151,7 +151,7 @@ void ApiListener::OnConfigLoaded(void)
void ApiListener::UpdateSSLContext(void) void ApiListener::UpdateSSLContext(void)
{ {
boost::shared_ptr<SSL_CTX> context; std::shared_ptr<SSL_CTX> context;
try { try {
context = MakeSSLContext(GetDefaultCertPath(), GetDefaultKeyPath(), GetDefaultCaPath()); context = MakeSSLContext(GetDefaultCertPath(), GetDefaultKeyPath(), GetDefaultCaPath());
@ -312,7 +312,7 @@ bool ApiListener::AddListener(const String& node, const String& service)
{ {
ObjectLock olock(this); ObjectLock olock(this);
boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext; std::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) { if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddListener()"); Log(LogCritical, "ApiListener", "SSL context is required for AddListener()");
@ -367,7 +367,7 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
{ {
ObjectLock olock(this); ObjectLock olock(this);
boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext; std::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) { if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()"); Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()");
@ -455,7 +455,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
return; return;
} }
boost::shared_ptr<X509> cert = tlsStream->GetPeerCertificate(); std::shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
String identity; String identity;
Endpoint::Ptr endpoint; Endpoint::Ptr endpoint;
bool verify_ok = false; bool verify_ok = false;

View File

@ -117,7 +117,7 @@ protected:
virtual void ValidateTlsProtocolmin(const String& value, const ValidationUtils& utils) override; virtual void ValidateTlsProtocolmin(const String& value, const ValidationUtils& utils) override;
private: private:
boost::shared_ptr<SSL_CTX> m_SSLContext; std::shared_ptr<SSL_CTX> m_SSLContext;
std::set<TcpSocket::Ptr> m_Servers; std::set<TcpSocket::Ptr> m_Servers;
mutable boost::mutex m_AnonymousClientsLock; mutable boost::mutex m_AnonymousClientsLock;

View File

@ -28,7 +28,6 @@
#include "base/tcpsocket.hpp" #include "base/tcpsocket.hpp"
#include "base/tlsstream.hpp" #include "base/tlsstream.hpp"
#include "base/networkstream.hpp" #include "base/networkstream.hpp"
#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga; using namespace icinga;
@ -104,14 +103,14 @@ bool HttpClientConnection::ProcessMessage(void)
return false; return false;
} }
const std::pair<boost::shared_ptr<HttpRequest>, HttpCompletionCallback>& currentRequest = *m_Requests.begin(); const std::pair<std::shared_ptr<HttpRequest>, HttpCompletionCallback>& currentRequest = *m_Requests.begin();
HttpRequest& request = *currentRequest.first.get(); HttpRequest& request = *currentRequest.first.get();
const HttpCompletionCallback& callback = currentRequest.second; const HttpCompletionCallback& callback = currentRequest.second;
if (!m_CurrentResponse) if (!m_CurrentResponse)
m_CurrentResponse = boost::make_shared<HttpResponse>(m_Stream, request); m_CurrentResponse = std::make_shared<HttpResponse>(m_Stream, request);
boost::shared_ptr<HttpResponse> currentResponse = m_CurrentResponse; std::shared_ptr<HttpResponse> currentResponse = m_CurrentResponse;
HttpResponse& response = *currentResponse.get(); HttpResponse& response = *currentResponse.get();
try { try {
@ -161,13 +160,13 @@ void HttpClientConnection::DataAvailableHandler(const Stream::Ptr& stream)
m_Stream->Close(); m_Stream->Close();
} }
boost::shared_ptr<HttpRequest> HttpClientConnection::NewRequest(void) std::shared_ptr<HttpRequest> HttpClientConnection::NewRequest(void)
{ {
Reconnect(); Reconnect();
return boost::make_shared<HttpRequest>(m_Stream); return std::make_shared<HttpRequest>(m_Stream);
} }
void HttpClientConnection::SubmitRequest(const boost::shared_ptr<HttpRequest>& request, void HttpClientConnection::SubmitRequest(const std::shared_ptr<HttpRequest>& request,
const HttpCompletionCallback& callback) const HttpCompletionCallback& callback)
{ {
m_Requests.push_back(std::make_pair(request, callback)); m_Requests.push_back(std::make_pair(request, callback));

View File

@ -50,18 +50,18 @@ public:
void Disconnect(void); void Disconnect(void);
boost::shared_ptr<HttpRequest> NewRequest(void); std::shared_ptr<HttpRequest> NewRequest(void);
typedef std::function<void(HttpRequest&, HttpResponse&)> HttpCompletionCallback; typedef std::function<void(HttpRequest&, HttpResponse&)> HttpCompletionCallback;
void SubmitRequest(const boost::shared_ptr<HttpRequest>& request, const HttpCompletionCallback& callback); void SubmitRequest(const std::shared_ptr<HttpRequest>& request, const HttpCompletionCallback& callback);
private: private:
String m_Host; String m_Host;
String m_Port; String m_Port;
bool m_Tls; bool m_Tls;
Stream::Ptr m_Stream; Stream::Ptr m_Stream;
std::deque<std::pair<boost::shared_ptr<HttpRequest>, HttpCompletionCallback> > m_Requests; std::deque<std::pair<std::shared_ptr<HttpRequest>, HttpCompletionCallback> > m_Requests;
boost::shared_ptr<HttpResponse> m_CurrentResponse; std::shared_ptr<HttpResponse> m_CurrentResponse;
boost::mutex m_DataHandlerMutex; boost::mutex m_DataHandlerMutex;
StreamReadContext m_Context; StreamReadContext m_Context;

View File

@ -24,7 +24,6 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga; using namespace icinga;
@ -101,7 +100,7 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
} else if (m_State == HttpRequestBody) { } else if (m_State == HttpRequestBody) {
if (Headers->Get("transfer-encoding") == "chunked") { if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext) if (!m_ChunkContext)
m_ChunkContext = boost::make_shared<ChunkReadContext>(boost::ref(src)); m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
char *data; char *data;
size_t size; size_t size;

View File

@ -71,7 +71,7 @@ public:
private: private:
Stream::Ptr m_Stream; Stream::Ptr m_Stream;
boost::shared_ptr<ChunkReadContext> m_ChunkContext; std::shared_ptr<ChunkReadContext> m_ChunkContext;
HttpRequestState m_State; HttpRequestState m_State;
FIFO::Ptr m_Body; FIFO::Ptr m_Body;

View File

@ -24,7 +24,6 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include "base/application.hpp" #include "base/application.hpp"
#include "base/convert.hpp" #include "base/convert.hpp"
#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga; using namespace icinga;
@ -183,7 +182,7 @@ bool HttpResponse::Parse(StreamReadContext& src, bool may_wait)
} else if (m_State == HttpResponseBody) { } else if (m_State == HttpResponseBody) {
if (Headers->Get("transfer-encoding") == "chunked") { if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext) if (!m_ChunkContext)
m_ChunkContext = boost::make_shared<ChunkReadContext>(boost::ref(src)); m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
char *data; char *data;
size_t size; size_t size;

View File

@ -67,7 +67,7 @@ public:
private: private:
HttpResponseState m_State; HttpResponseState m_State;
boost::shared_ptr<ChunkReadContext> m_ChunkContext; std::shared_ptr<ChunkReadContext> m_ChunkContext;
const HttpRequest& m_Request; const HttpRequest& m_Request;
Stream::Ptr m_Stream; Stream::Ptr m_Stream;
FIFO::Ptr m_Body; FIFO::Ptr m_Body;

View File

@ -45,7 +45,7 @@ Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictiona
String certText = params->Get("cert_request"); String certText = params->Get("cert_request");
boost::shared_ptr<X509> cert; std::shared_ptr<X509> cert;
Dictionary::Ptr result = new Dictionary(); Dictionary::Ptr result = new Dictionary();
@ -56,7 +56,7 @@ Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictiona
cert = StringToCertificate(certText); cert = StringToCertificate(certText);
ApiListener::Ptr listener = ApiListener::GetInstance(); ApiListener::Ptr listener = ApiListener::GetInstance();
boost::shared_ptr<X509> cacert = GetX509Certificate(listener->GetDefaultCaPath()); std::shared_ptr<X509> cacert = GetX509Certificate(listener->GetDefaultCaPath());
String cn = GetCertificateCN(cert); String cn = GetCertificateCN(cert);
@ -137,8 +137,8 @@ Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictiona
} }
} }
boost::shared_ptr<X509> newcert; std::shared_ptr<X509> newcert;
boost::shared_ptr<EVP_PKEY> pubkey; std::shared_ptr<EVP_PKEY> pubkey;
X509_NAME *subject; X509_NAME *subject;
Dictionary::Ptr message; Dictionary::Ptr message;
String ticket; String ticket;
@ -172,7 +172,7 @@ Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictiona
} }
} }
pubkey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free); pubkey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
subject = X509_get_subject_name(cert.get()); subject = X509_get_subject_name(cert.get());
newcert = CreateCertIcingaCA(pubkey.get(), subject); newcert = CreateCertIcingaCA(pubkey.get(), subject);
@ -285,8 +285,8 @@ Value UpdateCertificateHandler(const MessageOrigin::Ptr& origin, const Dictionar
if (!listener) if (!listener)
return Empty; return Empty;
boost::shared_ptr<X509> oldCert = GetX509Certificate(listener->GetDefaultCertPath()); std::shared_ptr<X509> oldCert = GetX509Certificate(listener->GetDefaultCertPath());
boost::shared_ptr<X509> newCert = StringToCertificate(cert); std::shared_ptr<X509> newCert = StringToCertificate(cert);
String cn = GetCertificateCN(newCert); String cn = GetCertificateCN(newCert);
@ -294,8 +294,8 @@ Value UpdateCertificateHandler(const MessageOrigin::Ptr& origin, const Dictionar
<< "Received certificate update message for CN '" << cn << "'"; << "Received certificate update message for CN '" << cn << "'";
/* Check if this is a certificate update for a subordinate instance. */ /* Check if this is a certificate update for a subordinate instance. */
boost::shared_ptr<EVP_PKEY> oldKey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(oldCert.get()), EVP_PKEY_free); std::shared_ptr<EVP_PKEY> oldKey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(oldCert.get()), EVP_PKEY_free);
boost::shared_ptr<EVP_PKEY> newKey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(newCert.get()), EVP_PKEY_free); std::shared_ptr<EVP_PKEY> newKey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(newCert.get()), EVP_PKEY_free);
if (X509_NAME_cmp(X509_get_subject_name(oldCert.get()), X509_get_subject_name(newCert.get())) != 0 || if (X509_NAME_cmp(X509_get_subject_name(oldCert.get()), X509_get_subject_name(newCert.get())) != 0 ||
EVP_PKEY_cmp(oldKey.get(), newKey.get()) != 1) { EVP_PKEY_cmp(oldKey.get(), newKey.get()) != 1) {

View File

@ -81,8 +81,8 @@ int PkiUtility::SignCsr(const String& csrfile, const String& certfile)
BIO_free(csrbio); BIO_free(csrbio);
boost::shared_ptr<EVP_PKEY> pubkey = boost::shared_ptr<EVP_PKEY>(X509_REQ_get_pubkey(req), EVP_PKEY_free); std::shared_ptr<EVP_PKEY> pubkey = std::shared_ptr<EVP_PKEY>(X509_REQ_get_pubkey(req), EVP_PKEY_free);
boost::shared_ptr<X509> cert = CreateCertIcingaCA(pubkey.get(), X509_REQ_get_subject_name(req)); std::shared_ptr<X509> cert = CreateCertIcingaCA(pubkey.get(), X509_REQ_get_subject_name(req));
X509_REQ_free(req); X509_REQ_free(req);
@ -91,7 +91,7 @@ int PkiUtility::SignCsr(const String& csrfile, const String& certfile)
return 0; return 0;
} }
boost::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& port) std::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& port)
{ {
TcpSocket::Ptr client = new TcpSocket(); TcpSocket::Ptr client = new TcpSocket();
@ -102,10 +102,10 @@ boost::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String&
<< "Cannot connect to host '" << host << "' on port '" << port << "'"; << "Cannot connect to host '" << host << "' on port '" << port << "'";
Log(LogDebug, "pki") Log(LogDebug, "pki")
<< "Cannot connect to host '" << host << "' on port '" << port << "':\n" << DiagnosticInformation(ex); << "Cannot connect to host '" << host << "' on port '" << port << "':\n" << DiagnosticInformation(ex);
return boost::shared_ptr<X509>(); return std::shared_ptr<X509>();
} }
boost::shared_ptr<SSL_CTX> sslContext; std::shared_ptr<SSL_CTX> sslContext;
try { try {
sslContext = MakeSSLContext(); sslContext = MakeSSLContext();
@ -114,7 +114,7 @@ boost::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String&
<< "Cannot make SSL context."; << "Cannot make SSL context.";
Log(LogDebug, "pki") Log(LogDebug, "pki")
<< "Cannot make SSL context:\n" << DiagnosticInformation(ex); << "Cannot make SSL context:\n" << DiagnosticInformation(ex);
return boost::shared_ptr<X509>(); return std::shared_ptr<X509>();
} }
TlsStream::Ptr stream = new TlsStream(client, host, RoleClient, sslContext); TlsStream::Ptr stream = new TlsStream(client, host, RoleClient, sslContext);
@ -128,7 +128,7 @@ boost::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String&
return stream->GetPeerCertificate(); return stream->GetPeerCertificate();
} }
int PkiUtility::WriteCert(const boost::shared_ptr<X509>& cert, const String& trustedfile) int PkiUtility::WriteCert(const std::shared_ptr<X509>& cert, const String& trustedfile)
{ {
std::ofstream fpcert; std::ofstream fpcert;
fpcert.open(trustedfile.CStr()); fpcert.open(trustedfile.CStr());
@ -155,7 +155,7 @@ int PkiUtility::GenTicket(const String& cn, const String& salt, std::ostream& ti
} }
int PkiUtility::RequestCertificate(const String& host, const String& port, const String& keyfile, int PkiUtility::RequestCertificate(const String& host, const String& port, const String& keyfile,
const String& certfile, const String& cafile, const boost::shared_ptr<X509>& trustedCert, const String& ticket) const String& certfile, const String& cafile, const std::shared_ptr<X509>& trustedCert, const String& ticket)
{ {
TcpSocket::Ptr client = new TcpSocket(); TcpSocket::Ptr client = new TcpSocket();
@ -169,7 +169,7 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
return 1; return 1;
} }
boost::shared_ptr<SSL_CTX> sslContext; std::shared_ptr<SSL_CTX> sslContext;
try { try {
sslContext = MakeSSLContext(certfile, keyfile); sslContext = MakeSSLContext(certfile, keyfile);
@ -190,7 +190,7 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
return 1; return 1;
} }
boost::shared_ptr<X509> peerCert = stream->GetPeerCertificate(); std::shared_ptr<X509> peerCert = stream->GetPeerCertificate();
if (X509_cmp(peerCert.get(), trustedCert.get())) { if (X509_cmp(peerCert.get(), trustedCert.get())) {
Log(LogCritical, "cli", "Peer certificate does not match trusted certificate."); Log(LogCritical, "cli", "Peer certificate does not match trusted certificate.");
@ -326,7 +326,7 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
return 0; return 0;
} }
String PkiUtility::GetCertificateInformation(const boost::shared_ptr<X509>& cert) { String PkiUtility::GetCertificateInformation(const std::shared_ptr<X509>& cert) {
BIO *out = BIO_new(BIO_s_mem()); BIO *out = BIO_new(BIO_s_mem());
String pre; String pre;
@ -391,7 +391,7 @@ static void CollectRequestHandler(const Dictionary::Ptr& requests, const String&
result->Set("cert_response", certResponseText); result->Set("cert_response", certResponseText);
} }
boost::shared_ptr<X509> certRequest = StringToCertificate(certRequestText); std::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
/* XXX (requires OpenSSL >= 1.0.0) /* XXX (requires OpenSSL >= 1.0.0)
time_t now; time_t now;

View File

@ -37,13 +37,13 @@ public:
static int NewCa(void); static int NewCa(void);
static int NewCert(const String& cn, const String& keyfile, const String& csrfile, const String& certfile); static int NewCert(const String& cn, const String& keyfile, const String& csrfile, const String& certfile);
static int SignCsr(const String& csrfile, const String& certfile); static int SignCsr(const String& csrfile, const String& certfile);
static boost::shared_ptr<X509> FetchCert(const String& host, const String& port); static std::shared_ptr<X509> FetchCert(const String& host, const String& port);
static int WriteCert(const boost::shared_ptr<X509>& cert, const String& trustedfile); static int WriteCert(const std::shared_ptr<X509>& cert, const String& trustedfile);
static int GenTicket(const String& cn, const String& salt, std::ostream& ticketfp); static int GenTicket(const String& cn, const String& salt, std::ostream& ticketfp);
static int RequestCertificate(const String& host, const String& port, const String& keyfile, static int RequestCertificate(const String& host, const String& port, const String& keyfile,
const String& certfile, const String& cafile, const boost::shared_ptr<X509>& trustedcert, const String& certfile, const String& cafile, const std::shared_ptr<X509>& trustedcert,
const String& ticket = String()); const String& ticket = String());
static String GetCertificateInformation(const boost::shared_ptr<X509>& certificate); static String GetCertificateInformation(const std::shared_ptr<X509>& certificate);
static Dictionary::Ptr GetCertificateRequests(void); static Dictionary::Ptr GetCertificateRequests(void);
private: private:

View File

@ -83,7 +83,7 @@ static Dictionary::Ptr QueryEndpoint(const String& host, const String& port, con
boost::condition_variable cv; boost::condition_variable cv;
boost::mutex mtx; boost::mutex mtx;
Dictionary::Ptr result; Dictionary::Ptr result;
boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest(); std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET"; req->RequestMethod = "GET";
// Url() will call Utillity::UnescapeString() which will thrown an exception if it finds a lonely % // Url() will call Utillity::UnescapeString() which will thrown an exception if it finds a lonely %