Skip to content

Commit

Permalink
rpc: fix internal daemon calls in restricted rpc getting partial data
Browse files Browse the repository at this point in the history
  • Loading branch information
moneromooo-monero committed Jan 11, 2019
1 parent 42abea7 commit 76c69fc
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 319 deletions.
12 changes: 6 additions & 6 deletions contrib/epee/include/net/http_server_handlers_map2.h
Expand Up @@ -54,7 +54,7 @@
bool handled = false; \ bool handled = false; \
if(false) return true; //just a stub to have "else if" if(false) return true; //just a stub to have "else if"


#define MAP_URI2(pattern, callback) else if(std::string::npos != query_info.m_URI.find(pattern)) return callback(query_info, response_info, m_conn_context); #define MAP_URI2(pattern, callback) else if(std::string::npos != query_info.m_URI.find(pattern)) return callback(query_info, response_info, &m_conn_context);


#define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type) //TODO: don't think i ever again will use xml - ambiguous and "overtagged" format #define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type) //TODO: don't think i ever again will use xml - ambiguous and "overtagged" format


Expand All @@ -69,7 +69,7 @@
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \ uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\ boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \ MINFO(m_conn_context << "calling " << s_pattern); \
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \ if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context)) \
{ \ { \
LOG_ERROR("Failed to " << #callback_f << "()"); \ LOG_ERROR("Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \ response_info.m_response_code = 500; \
Expand Down Expand Up @@ -97,7 +97,7 @@
uint64_t ticks1 = misc_utils::get_tick_count(); \ uint64_t ticks1 = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\ boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \ MINFO(m_conn_context << "calling " << s_pattern); \
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \ if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context)) \
{ \ { \
LOG_ERROR("Failed to " << #callback_f << "()"); \ LOG_ERROR("Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \ response_info.m_response_code = 500; \
Expand Down Expand Up @@ -182,7 +182,7 @@
fail_resp.jsonrpc = "2.0"; \ fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \ fail_resp.id = req.id; \
MINFO(m_conn_context << "Calling RPC method " << method_name); \ MINFO(m_conn_context << "Calling RPC method " << method_name); \
if(!callback_f(req.params, resp.result, fail_resp.error)) \ if(!callback_f(req.params, resp.result, fail_resp.error, &m_conn_context)) \
{ \ { \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \ epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \ return true; \
Expand All @@ -201,7 +201,7 @@
fail_resp.jsonrpc = "2.0"; \ fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \ fail_resp.id = req.id; \
MINFO(m_conn_context << "calling RPC method " << method_name); \ MINFO(m_conn_context << "calling RPC method " << method_name); \
if(!callback_f(req.params, resp.result, fail_resp.error, m_conn_context, response_info)) \ if(!callback_f(req.params, resp.result, fail_resp.error, response_info, &m_conn_context)) \
{ \ { \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \ epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \ return true; \
Expand All @@ -215,7 +215,7 @@
{ \ { \
PREPARE_OBJECTS_FROM_JSON(command_type) \ PREPARE_OBJECTS_FROM_JSON(command_type) \
MINFO(m_conn_context << "calling RPC method " << method_name); \ MINFO(m_conn_context << "calling RPC method " << method_name); \
if(!callback_f(req.params, resp.result)) \ if(!callback_f(req.params, resp.result, &m_conn_context)) \
{ \ { \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \ epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.jsonrpc = "2.0"; \ fail_resp.jsonrpc = "2.0"; \
Expand Down
6 changes: 3 additions & 3 deletions src/daemon/rpc_command_executor.cpp
Expand Up @@ -849,7 +849,7 @@ bool t_rpc_command_executor::print_transaction_pool_long() {
} }
else else
{ {
if (!m_rpc_server->on_get_transaction_pool(req, res, false) || res.status != CORE_RPC_STATUS_OK) if (!m_rpc_server->on_get_transaction_pool(req, res) || res.status != CORE_RPC_STATUS_OK)
{ {
tools::fail_msg_writer() << make_error(fail_message, res.status); tools::fail_msg_writer() << make_error(fail_message, res.status);
return true; return true;
Expand Down Expand Up @@ -935,7 +935,7 @@ bool t_rpc_command_executor::print_transaction_pool_short() {
} }
else else
{ {
if (!m_rpc_server->on_get_transaction_pool(req, res, false) || res.status != CORE_RPC_STATUS_OK) if (!m_rpc_server->on_get_transaction_pool(req, res) || res.status != CORE_RPC_STATUS_OK)
{ {
tools::fail_msg_writer() << make_error(fail_message, res.status); tools::fail_msg_writer() << make_error(fail_message, res.status);
return true; return true;
Expand Down Expand Up @@ -993,7 +993,7 @@ bool t_rpc_command_executor::print_transaction_pool_stats() {
else else
{ {
res.pool_stats = {}; res.pool_stats = {};
if (!m_rpc_server->on_get_transaction_pool_stats(req, res, false) || res.status != CORE_RPC_STATUS_OK) if (!m_rpc_server->on_get_transaction_pool_stats(req, res) || res.status != CORE_RPC_STATUS_OK)
{ {
tools::fail_msg_writer() << make_error(fail_message, res.status); tools::fail_msg_writer() << make_error(fail_message, res.status);
return true; return true;
Expand Down

0 comments on commit 76c69fc

Please sign in to comment.