aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/depends/packages/ncurses.mk8
-rw-r--r--contrib/depends/packages/readline.mk5
-rw-r--r--contrib/depends/toolchain.cmake.in23
-rw-r--r--contrib/epee/include/misc_log_ex.h68
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl29
-rw-r--r--contrib/epee/include/net/net_helper.h5
-rw-r--r--contrib/epee/include/net/net_ssl.h6
-rw-r--r--contrib/epee/src/CMakeLists.txt4
-rw-r--r--contrib/epee/src/connection_basic.cpp2
-rw-r--r--contrib/epee/src/mlog.cpp52
-rw-r--r--contrib/epee/src/net_ssl.cpp27
-rwxr-xr-xcontrib/gitian/gitian-build.py65
-rw-r--r--contrib/lsan/lsan.supp1
13 files changed, 216 insertions, 79 deletions
diff --git a/contrib/depends/packages/ncurses.mk b/contrib/depends/packages/ncurses.mk
index 4e06c00d9..c3b16baab 100644
--- a/contrib/depends/packages/ncurses.mk
+++ b/contrib/depends/packages/ncurses.mk
@@ -21,6 +21,7 @@ define $(package)_set_vars
$(package)_config_opts+=--without-tests
$(package)_config_opts+=--without-tack
$(package)_config_opts+=--without-manpages
+ $(package)_config_opts+=--with-termlib=tinfo
$(package)_config_opts+=--disable-tic-depends
$(package)_config_opts+=--disable-big-strings
$(package)_config_opts+=--disable-ext-colors
@@ -30,15 +31,16 @@ define $(package)_set_vars
$(pacakge)_config_opts+=--without-pthread
$(pacakge)_config_opts+=--disable-rpath
$(pacakge)_config_opts+=--disable-colorfgbg
- $(pacakge)_config_opts+=--disable-ext-colors
$(pacakge)_config_opts+=--disable-ext-mouse
$(pacakge)_config_opts+=--disable-symlinks
$(pacakge)_config_opts+=--enable-warnings
$(pacakge)_config_opts+=--enable-assertions
$(pacakge)_config_opts+=--disable-home-terminfo
+ $(package)_config_opts+=--with-default-terminfo-dir=/etc/terminfo
+ $(package)_config_opts+=--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo"
$(pacakge)_config_opts+=--enable-database
$(pacakge)_config_opts+=--enable-sp-funcs
- $(pacakge)_config_opts+=--enable-term-driver
+ $(pacakge)_config_opts+=--disable-term-driver
$(pacakge)_config_opts+=--enable-interop
$(pacakge)_config_opts+=--enable-widec
$(package)_build_opts=CFLAGS="$($(package)_cflags) $($(package)_cppflags) -fPIC"
@@ -53,6 +55,6 @@ define $(package)_build_cmds
endef
define $(package)_stage_cmds
- $(MAKE) install DESTDIR=$($(package)_staging_dir)
+ $(MAKE) install.libs DESTDIR=$($(package)_staging_dir)
endef
diff --git a/contrib/depends/packages/readline.mk b/contrib/depends/packages/readline.mk
index 0e2100749..8f234ab6a 100644
--- a/contrib/depends/packages/readline.mk
+++ b/contrib/depends/packages/readline.mk
@@ -6,7 +6,10 @@ $(package)_sha256_hash=e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078
$(package)_dependencies=ncurses
define $(package)_set_vars
- $(package)_config_opts=--prefix=$(host_prefix)
+ $(package)_build_opts=CC="$($(package)_cc)"
+ $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
+ $(package)_config_env_darwin=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
+ $(package)_config_opts+=--prefix=$(host_prefix)
$(package)_config_opts+=--exec-prefix=$(host_prefix)
$(package)_config_opts+=--host=$(HOST)
$(package)_config_opts+=--disable-shared --with-curses
diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in
index b748f5c55..ebe96b69c 100644
--- a/contrib/depends/toolchain.cmake.in
+++ b/contrib/depends/toolchain.cmake.in
@@ -22,7 +22,8 @@ SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE)
SET(Readline_ROOT_DIR @prefix@)
SET(Readline_INCLUDE_DIR @prefix@/include)
-SET(Termcap_LIBRARY @prefix@/lib/libncurses.a)
+SET(Readline_LIBRARY @prefix@/lib/libreadline.a)
+SET(Termcap_LIBRARY @prefix@/lib/libtinfo.a)
SET(LIBUNWIND_INCLUDE_DIR @prefix@/include)
SET(LIBUNWIND_LIBRARIES @prefix@/lib/libunwind.a)
@@ -40,14 +41,14 @@ SET(Protobuf_LIBRARY @prefix@/lib/libprotobuf.a CACHE FILEPATH "Protobuf library
SET(ZMQ_INCLUDE_PATH @prefix@/include)
SET(ZMQ_LIB @prefix@/lib/libzmq.a)
-SET(BOOST_IGNORE_SYSTEM_PATHS_DEFAULT ON)
-SET(BOOST_IGNORE_SYSTEM_PATH ON)
+SET(Boost_IGNORE_SYSTEM_PATH ON)
SET(BOOST_ROOT @prefix@)
+SET(BOOST_INCLUDEDIR @prefix@/include)
SET(BOOST_LIBRARYDIR @prefix@/lib)
-SET(BOOST_IGNORE_SYSTEM_PATHS_DEFAULT OFF)
-SET(BOOST_NO_SYSTEM_PATHS TRUE)
-SET(BOOST_USE_STATIC_LIBS TRUE)
-SET(BOOST_USE_STATIC_RUNTIME TRUE)
+SET(Boost_IGNORE_SYSTEM_PATHS_DEFAULT OFF)
+SET(Boost_NO_SYSTEM_PATHS ON)
+SET(Boost_USE_STATIC_LIBS ON)
+SET(Boost_USE_STATIC_RUNTIME ON)
SET(OpenSSL_DIR @prefix@/lib)
SET(ARCHITECTURE @arch@)
@@ -103,12 +104,14 @@ if(ARCHITECTURE STREQUAL "riscv64")
set(ARCH "rv64imafdc")
endif()
-if(ARCHITECTURE STREQUAL "i686" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
- SET(LINUX_32 ON)
+if(ARCHITECTURE STREQUAL "i686")
SET(ARCH_ID "i386")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ SET(LINUX_32 ON)
+ endif()
endif()
-if(ARCHITECTURE STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(ARCHITECTURE STREQUAL "x86_64")
SET(ARCH_ID "x86_64")
endif()
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h
index 602b6a371..3be335e85 100644
--- a/contrib/epee/include/misc_log_ex.h
+++ b/contrib/epee/include/misc_log_ex.h
@@ -28,6 +28,8 @@
#ifndef _MISC_LOG_EX_H_
#define _MISC_LOG_EX_H_
+#ifdef __cplusplus
+
#include <string>
#include "easylogging++.h"
@@ -38,29 +40,29 @@
#define MAX_LOG_FILE_SIZE 104850000 // 100 MB - 7600 bytes
#define MAX_LOG_FILES 50
-#define MCLOG_TYPE(level, cat, type, x) do { \
+#define MCLOG_TYPE(level, cat, color, type, x) do { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
- el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
+ el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \
} while (0)
-#define MCLOG(level, cat, x) MCLOG_TYPE(level, cat, el::base::DispatchAction::NormalLog, x)
-#define MCLOG_FILE(level, cat, x) MCLOG_TYPE(level, cat, el::base::DispatchAction::FileOnlyLog, x)
+#define MCLOG(level, cat, color, x) MCLOG_TYPE(level, cat, color, el::base::DispatchAction::NormalLog, x)
+#define MCLOG_FILE(level, cat, x) MCLOG_TYPE(level, cat, el::Color::Default, el::base::DispatchAction::FileOnlyLog, x)
-#define MCFATAL(cat,x) MCLOG(el::Level::Fatal,cat, x)
-#define MCERROR(cat,x) MCLOG(el::Level::Error,cat, x)
-#define MCWARNING(cat,x) MCLOG(el::Level::Warning,cat, x)
-#define MCINFO(cat,x) MCLOG(el::Level::Info,cat, x)
-#define MCDEBUG(cat,x) MCLOG(el::Level::Debug,cat, x)
-#define MCTRACE(cat,x) MCLOG(el::Level::Trace,cat, x)
+#define MCFATAL(cat,x) MCLOG(el::Level::Fatal,cat, el::Color::Default, x)
+#define MCERROR(cat,x) MCLOG(el::Level::Error,cat, el::Color::Default, x)
+#define MCWARNING(cat,x) MCLOG(el::Level::Warning,cat, el::Color::Default, x)
+#define MCINFO(cat,x) MCLOG(el::Level::Info,cat, el::Color::Default, x)
+#define MCDEBUG(cat,x) MCLOG(el::Level::Debug,cat, el::Color::Default, x)
+#define MCTRACE(cat,x) MCLOG(el::Level::Trace,cat, el::Color::Default, x)
-#define MCLOG_COLOR(level,cat,color,x) MCLOG(level,cat,"\033[1;" color "m" << x << "\033[0m")
-#define MCLOG_RED(level,cat,x) MCLOG_COLOR(level,cat,"31",x)
-#define MCLOG_GREEN(level,cat,x) MCLOG_COLOR(level,cat,"32",x)
-#define MCLOG_YELLOW(level,cat,x) MCLOG_COLOR(level,cat,"33",x)
-#define MCLOG_BLUE(level,cat,x) MCLOG_COLOR(level,cat,"34",x)
-#define MCLOG_MAGENTA(level,cat,x) MCLOG_COLOR(level,cat,"35",x)
-#define MCLOG_CYAN(level,cat,x) MCLOG_COLOR(level,cat,"36",x)
+#define MCLOG_COLOR(level,cat,color,x) MCLOG(level,cat,color,x)
+#define MCLOG_RED(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Red,x)
+#define MCLOG_GREEN(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Green,x)
+#define MCLOG_YELLOW(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Yellow,x)
+#define MCLOG_BLUE(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Blue,x)
+#define MCLOG_MAGENTA(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Magenta,x)
+#define MCLOG_CYAN(level,cat,x) MCLOG_COLOR(level,cat,el::Color::Cyan,x)
#define MLOG_RED(level,x) MCLOG_RED(level,MONERO_DEFAULT_LOG_CATEGORY,x)
#define MLOG_GREEN(level,x) MCLOG_GREEN(level,MONERO_DEFAULT_LOG_CATEGORY,x)
@@ -75,7 +77,7 @@
#define MINFO(x) MCINFO(MONERO_DEFAULT_LOG_CATEGORY,x)
#define MDEBUG(x) MCDEBUG(MONERO_DEFAULT_LOG_CATEGORY,x)
#define MTRACE(x) MCTRACE(MONERO_DEFAULT_LOG_CATEGORY,x)
-#define MLOG(level,x) MCLOG(level,MONERO_DEFAULT_LOG_CATEGORY,x)
+#define MLOG(level,x) MCLOG(level,MONERO_DEFAULT_LOG_CATEGORY,el::Color::Default,x)
#define MGINFO(x) MCINFO("global",x)
#define MGINFO_RED(x) MCLOG_RED(el::Level::Info, "global",x)
@@ -85,14 +87,14 @@
#define MGINFO_MAGENTA(x) MCLOG_MAGENTA(el::Level::Info, "global",x)
#define MGINFO_CYAN(x) MCLOG_CYAN(el::Level::Info, "global",x)
-#define IFLOG(level, cat, type, init, x) \
+#define IFLOG(level, cat, color, type, init, x) \
do { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
init; \
- el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
+ el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \
} while(0)
-#define MIDEBUG(init, x) IFLOG(el::Level::Debug, MONERO_DEFAULT_LOG_CATEGORY, el::base::DispatchAction::NormalLog, init, x)
+#define MIDEBUG(init, x) IFLOG(el::Level::Debug, MONERO_DEFAULT_LOG_CATEGORY, el::Color::Default, el::base::DispatchAction::NormalLog, init, x)
#define LOG_ERROR(x) MERROR(x)
@@ -220,4 +222,28 @@ void set_console_color(int color, bool bright);
void reset_console_color();
}
+
+extern "C"
+{
+
+#endif
+
+#ifdef __GNUC__
+#define ATTRIBUTE_PRINTF __attribute__((format(printf, 2, 3)))
+#else
+#define ATTRIBUTE_PRINTF
+#endif
+
+bool merror(const char *category, const char *format, ...) ATTRIBUTE_PRINTF;
+bool mwarning(const char *category, const char *format, ...) ATTRIBUTE_PRINTF;
+bool minfo(const char *category, const char *format, ...) ATTRIBUTE_PRINTF;
+bool mdebug(const char *category, const char *format, ...) ATTRIBUTE_PRINTF;
+bool mtrace(const char *category, const char *format, ...) ATTRIBUTE_PRINTF;
+
+#ifdef __cplusplus
+
+}
+
+#endif
+
#endif //_MISC_LOG_EX_H_
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 12a87071a..c52535dcd 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -50,6 +50,8 @@
#include <sstream>
#include <iomanip>
#include <algorithm>
+#include <functional>
+#include <random>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
@@ -154,7 +156,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
}
else
{
- const auto ip_{remote_ep.address().to_v6()};
+ const auto ip_ = remote_ep.address().to_v6();
return start(is_income, is_multithreaded, ipv6_network_address{ip_, remote_ep.port()});
}
CATCH_ENTRY_L0("connection<t_protocol_handler>::start()", false);
@@ -557,7 +559,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
while (!message.empty()) {
byte_slice chunk = message.take_slice(chunksize_good);
- MDEBUG("chunk_start="<<chunk.data()<<" ptr="<<message_data<<" pos="<<(chunk.data() - message_data));
+ MDEBUG("chunk_start="<<(void*)chunk.data()<<" ptr="<<message_data<<" pos="<<(chunk.data() - message_data));
MDEBUG("part of " << message.size() << ": pos="<<(chunk.data() - message_data) << " len="<<chunk.size());
bool ok = do_send_chunk(std::move(chunk)); // <====== ***
@@ -628,7 +630,17 @@ PRAGMA_WARNING_DISABLE_VS(4355)
return false; // aborted
}*/
- long int ms = 250 + (rand()%50);
+ using engine = std::mt19937;
+
+ engine rng;
+ std::random_device dev;
+ std::seed_seq::result_type rand[engine::state_size]{}; // Use complete bit space
+
+ std::generate_n(rand, engine::state_size, std::ref(dev));
+ std::seed_seq seed(rand, rand + engine::state_size);
+ rng.seed(seed);
+
+ long int ms = 250 + (rng() % 50);
MDEBUG("Sleeping because QUEUE is FULL, in " << __FUNCTION__ << " for " << ms << " ms before packet_size="<<chunk.size()); // XXX debug sleep
m_send_que_lock.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
@@ -736,6 +748,11 @@ PRAGMA_WARNING_DISABLE_VS(4355)
MERROR("Resetting timer on a dead object");
return;
}
+ if (m_was_shutdown)
+ {
+ MERROR("Setting timer on a shut down object");
+ return;
+ }
if (add)
ms += m_timer.expires_from_now();
m_timer.expires_from_now(ms);
@@ -967,8 +984,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
boost::asio::ip::tcp::resolver::query query(address, boost::lexical_cast<std::string>(port), boost::asio::ip::tcp::resolver::query::canonical_name);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
acceptor_.open(endpoint.protocol());
- // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
- acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+ acceptor_.set_option(boost::asio::ip::tcp::acceptor::linger(true, 0));
acceptor_.bind(endpoint);
acceptor_.listen();
boost::asio::ip::tcp::endpoint binded_endpoint = acceptor_.local_endpoint();
@@ -1002,8 +1018,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
boost::asio::ip::tcp::resolver::query query(address_ipv6, boost::lexical_cast<std::string>(port_ipv6), boost::asio::ip::tcp::resolver::query::canonical_name);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
acceptor_ipv6.open(endpoint.protocol());
- // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
- acceptor_ipv6.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+ acceptor_ipv6.set_option(boost::asio::ip::tcp::acceptor::linger(true, 0));
acceptor_ipv6.set_option(boost::asio::ip::v6_only(true));
acceptor_ipv6.bind(endpoint);
acceptor_ipv6.listen();
diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h
index 2b02eafa4..81545e502 100644
--- a/contrib/epee/include/net/net_helper.h
+++ b/contrib/epee/include/net/net_helper.h
@@ -108,11 +108,12 @@ namespace net_utils
m_ssl_options(epee::net_utils::ssl_support_t::e_ssl_support_autodetect),
m_initialized(true),
m_connected(false),
- m_deadline(m_io_service),
+ m_deadline(m_io_service, std::chrono::steady_clock::time_point::max()),
m_shutdowned(0),
m_bytes_sent(0),
m_bytes_received(0)
{
+ check_deadline();
}
/*! The first/second parameters are host/port respectively. The third
@@ -177,7 +178,7 @@ namespace net_utils
// SSL Options
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
{
- if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, addr))
+ if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, addr, timeout))
{
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
{
diff --git a/contrib/epee/include/net/net_ssl.h b/contrib/epee/include/net/net_ssl.h
index 3a97dfdaf..d2c1c1a3a 100644
--- a/contrib/epee/include/net/net_ssl.h
+++ b/contrib/epee/include/net/net_ssl.h
@@ -128,7 +128,11 @@ namespace net_utils
\return True if the SSL handshake completes with peer verification
settings. */
- bool handshake(boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket, boost::asio::ssl::stream_base::handshake_type type, const std::string& host = {}) const;
+ bool handshake(
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
+ boost::asio::ssl::stream_base::handshake_type type,
+ const std::string& host = {},
+ std::chrono::milliseconds timeout = std::chrono::seconds(15)) const;
};
// https://security.stackexchange.com/questions/34780/checking-client-hello-for-https-classification
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt
index c512e3b86..9b9fa5a47 100644
--- a/contrib/epee/src/CMakeLists.txt
+++ b/contrib/epee/src/CMakeLists.txt
@@ -29,7 +29,7 @@
add_library(epee STATIC byte_slice.cpp hex.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp
levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp)
-if (USE_READLINE AND GNU_READLINE_FOUND)
+if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
add_library(epee_readline STATIC readline_buffer.cpp)
endif()
@@ -62,7 +62,7 @@ target_link_libraries(epee
${OPENSSL_LIBRARIES}
${EXTRA_LIBRARIES})
-if (USE_READLINE AND GNU_READLINE_FOUND)
+if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
target_link_libraries(epee_readline
PUBLIC
easylogging
diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp
index 7526dde26..3ce7a1057 100644
--- a/contrib/epee/src/connection_basic.cpp
+++ b/contrib/epee/src/connection_basic.cpp
@@ -136,6 +136,7 @@ connection_basic::connection_basic(boost::asio::ip::tcp::socket&& sock, std::sha
socket_(GET_IO_SERVICE(sock), get_context(m_state.get())),
m_want_close_connection(false),
m_was_shutdown(false),
+ m_is_multithreaded(false),
m_ssl_support(ssl_support)
{
// add nullptr checks if removed
@@ -160,6 +161,7 @@ connection_basic::connection_basic(boost::asio::io_service &io_service, std::sha
socket_(io_service, get_context(m_state.get())),
m_want_close_connection(false),
m_was_shutdown(false),
+ m_is_multithreaded(false),
m_ssl_support(ssl_support)
{
// add nullptr checks if removed
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index 4c6ad5516..66dfabcdf 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -109,7 +109,7 @@ static const char *get_default_categories(int level)
categories = "*:DEBUG";
break;
case 3:
- categories = "*:TRACE";
+ categories = "*:TRACE,*.dump:DEBUG";
break;
case 4:
categories = "*:TRACE";
@@ -472,4 +472,54 @@ void reset_console_color() {
}
+static bool mlog(el::Level level, const char *category, const char *format, va_list ap) noexcept
+{
+ int size = 0;
+ char *p = NULL;
+ va_list apc;
+ bool ret = true;
+
+ /* Determine required size */
+ va_copy(apc, ap);
+ size = vsnprintf(p, size, format, apc);
+ va_end(apc);
+ if (size < 0)
+ return false;
+
+ size++; /* For '\0' */
+ p = (char*)malloc(size);
+ if (p == NULL)
+ return false;
+
+ size = vsnprintf(p, size, format, ap);
+ if (size < 0)
+ {
+ free(p);
+ return false;
+ }
+
+ try
+ {
+ MCLOG(level, category, el::Color::Default, p);
+ }
+ catch(...)
+ {
+ ret = false;
+ }
+ free(p);
+
+ return ret;
+}
+
+#define DEFLOG(fun,lev) \
+ bool m##fun(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bool ret = mlog(el::Level::lev, category, fmt, ap); va_end(ap); return ret; }
+
+DEFLOG(error, Error)
+DEFLOG(warning, Warning)
+DEFLOG(info, Info)
+DEFLOG(debug, Debug)
+DEFLOG(trace, Trace)
+
+#undef DEFLOG
+
#endif //_MLOG_H_
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp
index 7d48d2a64..c7dca1914 100644
--- a/contrib/epee/src/net_ssl.cpp
+++ b/contrib/epee/src/net_ssl.cpp
@@ -28,9 +28,11 @@
#include <string.h>
#include <boost/asio/ssl.hpp>
+#include <boost/lambda/lambda.hpp>
#include <openssl/ssl.h>
#include <openssl/pem.h>
#include "misc_log_ex.h"
+#include "net/net_helper.h"
#include "net/net_ssl.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -456,7 +458,11 @@ bool ssl_options_t::has_fingerprint(boost::asio::ssl::verify_context &ctx) const
return false;
}
-bool ssl_options_t::handshake(boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket, boost::asio::ssl::stream_base::handshake_type type, const std::string& host) const
+bool ssl_options_t::handshake(
+ boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
+ boost::asio::ssl::stream_base::handshake_type type,
+ const std::string& host,
+ std::chrono::milliseconds timeout) const
{
socket.next_layer().set_option(boost::asio::ip::tcp::no_delay(true));
@@ -502,8 +508,23 @@ bool ssl_options_t::handshake(boost::asio::ssl::stream<boost::asio::ip::tcp::soc
});
}
- boost::system::error_code ec;
- socket.handshake(type, ec);
+ auto& io_service = GET_IO_SERVICE(socket);
+ boost::asio::steady_timer deadline(io_service, timeout);
+ deadline.async_wait([&socket](const boost::system::error_code& error) {
+ if (error != boost::asio::error::operation_aborted)
+ {
+ socket.next_layer().close();
+ }
+ });
+
+ boost::system::error_code ec = boost::asio::error::would_block;
+ socket.async_handshake(type, boost::lambda::var(ec) = boost::lambda::_1);
+ while (ec == boost::asio::error::would_block)
+ {
+ io_service.reset();
+ io_service.run_one();
+ }
+
if (ec)
{
MERROR("SSL handshake failed, connection dropped: " << ec.message());
diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py
index 5913fda3a..a8d164c2c 100755
--- a/contrib/gitian/gitian-build.py
+++ b/contrib/gitian/gitian-build.py
@@ -5,6 +5,9 @@ import os
import subprocess
import sys
+gsigs = 'https://github.com/monero-project/gitian.sigs.git'
+gbrepo = 'https://github.com/devrandom/gitian-builder.git'
+
def setup():
global args, workdir
programs = ['apt-cacher-ng', 'ruby', 'git', 'make', 'wget']
@@ -14,14 +17,21 @@ def setup():
programs += ['lxc', 'debootstrap']
if not args.no_apt:
subprocess.check_call(['sudo', 'apt-get', 'install', '-qq'] + programs)
- if not os.path.isdir('gitian.sigs'):
- subprocess.check_call(['git', 'clone', 'https://github.com/monero-project/gitian.sigs.git'])
- if not os.path.isdir('gitian-builder'):
- subprocess.check_call(['git', 'clone', 'https://github.com/devrandom/gitian-builder.git'])
- if not os.path.isdir('monero'):
- subprocess.check_call(['git', 'clone', 'https://github.com/monero-project/monero.git'])
- os.chdir('gitian-builder')
+ if not os.path.isdir('sigs'):
+ subprocess.check_call(['git', 'clone', gsigs, 'sigs'])
+ if not os.path.isdir('builder'):
+ subprocess.check_call(['git', 'clone', gbrepo, 'builder'])
+ os.chdir('builder')
+ subprocess.check_call(['git', 'config', 'user.email', 'gitianuser@localhost'])
+ subprocess.check_call(['git', 'config', 'user.name', 'gitianuser'])
subprocess.check_call(['git', 'checkout', '963322de8420c50502c4cc33d4d7c0d84437b576'])
+ subprocess.check_call(['git', 'fetch', 'origin', '72c51f0bd2adec4eedab4dbd06c9229b9c4eb0e3'])
+ subprocess.check_call(['git', 'cherry-pick', '72c51f0bd2adec4eedab4dbd06c9229b9c4eb0e3'])
+ os.makedirs('inputs', exist_ok=True)
+ os.chdir('inputs')
+ if not os.path.isdir('monero'):
+ subprocess.check_call(['git', 'clone', args.url, 'monero'])
+ os.chdir('..')
make_image_prog = ['bin/make-base-vm', '--suite', 'bionic', '--arch', 'amd64']
if args.docker:
if not subprocess.call(['docker', '--help'], shell=False, stdout=subprocess.DEVNULL):
@@ -39,40 +49,40 @@ def setup():
def build():
global args, workdir
- os.makedirs('monero-binaries/' + args.version, exist_ok=True)
+ os.makedirs('out/' + args.version, exist_ok=True)
print('\nBuilding Dependencies\n')
- os.chdir('gitian-builder')
+ os.chdir('builder')
os.makedirs('inputs', exist_ok=True)
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz'])
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'])
subprocess.check_output(["echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 inputs/osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c"], shell=True)
subprocess.check_output(["echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs/osslsigncode-1.7.1.tar.gz' | sha256sum -c"], shell=True)
- subprocess.check_call(['make', '-C', '../monero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
+ subprocess.check_call(['make', '-C', 'inputs/monero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
if args.linux:
print('\nCompiling ' + args.version + ' Linux')
- subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, '../monero/contrib/gitian/gitian-linux.yml'])
- subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-linux', '--destination', '../gitian.sigs/', '../monero/contrib/gitian/gitian-linux.yml'])
- subprocess.check_call('mv build/out/monero-*.tar.bz2 ../monero-binaries/'+args.version, shell=True)
+ subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, 'inputs/monero/contrib/gitian/gitian-linux.yml'])
+ subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-linux', '--destination', '../sigs/', 'inputs/monero/contrib/gitian/gitian-linux.yml'])
+ subprocess.check_call('mv build/out/monero-*.tar.bz2 ../out/'+args.version, shell=True)
if args.windows:
print('\nCompiling ' + args.version + ' Windows')
- subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, '../monero/contrib/gitian/gitian-win.yml'])
- subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-win', '--destination', '../gitian.sigs/', '../monero/contrib/gitian/gitian-win.yml'])
- subprocess.check_call('mv build/out/monero*.zip ../monero-binaries/'+args.version, shell=True)
+ subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, 'inputs/monero/contrib/gitian/gitian-win.yml'])
+ subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-win', '--destination', '../sigs/', 'inputs/monero/contrib/gitian/gitian-win.yml'])
+ subprocess.check_call('mv build/out/monero*.zip ../out/'+args.version, shell=True)
if args.macos:
print('\nCompiling ' + args.version + ' MacOS')
- subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, '../monero/contrib/gitian/gitian-osx.yml'])
- subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-osx', '--destination', '../gitian.sigs/', '../monero/contrib/gitian/gitian-osx.yml'])
- subprocess.check_call('mv build/out/monero*.tar.bz2 ../monero-binaries/'+args.version, shell=True)
+ subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero'+args.url, 'inputs/monero/contrib/gitian/gitian-osx.yml'])
+ subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-osx', '--destination', '../sigs/', 'inputs/monero/contrib/gitian/gitian-osx.yml'])
+ subprocess.check_call('mv build/out/monero*.tar.bz2 ../out/'+args.version, shell=True)
os.chdir(workdir)
if args.commit_files:
print('\nCommitting '+args.version+' Unsigned Sigs\n')
- os.chdir('gitian.sigs')
+ os.chdir('sigs')
subprocess.check_call(['git', 'add', args.version+'-linux/'+args.signer])
subprocess.check_call(['git', 'add', args.version+'-win/'+args.signer])
subprocess.check_call(['git', 'add', args.version+'-osx/'+args.signer])
@@ -81,14 +91,14 @@ def build():
def verify():
global args, workdir
- os.chdir('gitian-builder')
+ os.chdir('builder')
print('\nVerifying v'+args.version+' Linux\n')
- subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-linux', '../monero/contrib/gitian/gitian-linux.yml'])
+ subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-linux', 'inputs/monero/contrib/gitian/gitian-linux.yml'])
print('\nVerifying v'+args.version+' Windows\n')
- subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-win', '../monero/contrib/gitian/gitian-win.yml'])
+ subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-win', 'inputs/monero/contrib/gitian/gitian-win.yml'])
print('\nVerifying v'+args.version+' MacOS\n')
- subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-osx', '../monero/contrib/gitian/gitian-osx.yml'])
+ subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-osx', 'inputs/monero/contrib/gitian/gitian-osx.yml'])
os.chdir(workdir)
def main():
@@ -142,7 +152,7 @@ def main():
os.environ['LXC_GUEST_IP'] = '10.0.3.5'
# Disable MacOS build if no SDK found
- if args.build and args.macos and not os.path.isfile('gitian-builder/inputs/MacOSX10.11.sdk.tar.gz'):
+ if args.build and args.macos and not os.path.isfile('builder/inputs/MacOSX10.11.sdk.tar.gz'):
print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
args.macos = False
@@ -165,11 +175,10 @@ def main():
if args.setup:
setup()
- os.chdir('monero')
+ os.makedirs('builder/inputs/monero', exist_ok=True)
+ os.chdir('builder/inputs/monero')
if args.pull:
subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
- os.chdir('../gitian-builder/inputs/monero')
- subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
args.commit = subprocess.check_output(['git', 'show', '-s', '--format=%H', 'FETCH_HEAD'], universal_newlines=True).strip()
args.version = 'pull-' + args.version
print(args.commit)
diff --git a/contrib/lsan/lsan.supp b/contrib/lsan/lsan.supp
new file mode 100644
index 000000000..4aef353c6
--- /dev/null
+++ b/contrib/lsan/lsan.supp
@@ -0,0 +1 @@
+leak:slow_hash_allocate_state