aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--README.md5
-rw-r--r--VULNERABILITY_RESPONSE_PROCESS.md143
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/blockchain_utilities/CMakeLists.txt6
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/apply_permutation.h68
-rw-r--r--src/cryptonote_core/CMakeLists.txt1
-rw-r--r--src/cryptonote_core/blockchain.cpp39
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp36
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.h2
-rw-r--r--src/cryptonote_protocol/CMakeLists.txt2
-rw-r--r--src/daemon/CMakeLists.txt2
-rw-r--r--src/debug_utilities/CMakeLists.txt4
-rw-r--r--src/p2p/CMakeLists.txt2
-rw-r--r--src/p2p/net_node.inl2
-rw-r--r--src/rpc/CMakeLists.txt7
-rw-r--r--src/simplewallet/CMakeLists.txt3
-rw-r--r--src/version.cmake4
-rw-r--r--src/version.cpp.in9
-rw-r--r--src/version.h6
-rw-r--r--src/version.h.in4
-rw-r--r--src/wallet/CMakeLists.txt3
-rw-r--r--src/wallet/wallet_rpc_server.cpp2
-rw-r--r--tests/core_proxy/CMakeLists.txt1
-rw-r--r--tests/core_tests/CMakeLists.txt1
-rw-r--r--tests/libwallet_api_tests/CMakeLists.txt1
-rw-r--r--tests/unit_tests/CMakeLists.txt2
-rw-r--r--tests/unit_tests/apply_permutation.cpp74
-rw-r--r--utils/systemd/monerod.service5
-rw-r--r--version.cmake47
31 files changed, 289 insertions, 198 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 486a80b4e..842eea734 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,7 +186,7 @@ endif()
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
# set(BSDI TRUE)
-include_directories(external/easylogging++ src contrib/epee/include external "${CMAKE_BINARY_DIR}/version")
+include_directories(external/easylogging++ src contrib/epee/include external)
if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
diff --git a/README.md b/README.md
index 2087a5639..92568c557 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,11 @@ Portions Copyright (c) 2012-2013, The Cryptonote developers
- GitHub: [https://github.com/monero-project/monero](https://github.com/monero-project/monero)
- IRC: [#monero-dev on Freenode](http://webchat.freenode.net/?randomnick=1&channels=%23monero-dev&prompt=1&uio=d4)
+## Vulnerability Response
+
+- Our [Vulnerability Response Process](https://github.com/monero-project/meta/blob/master/VULNERABILITY_RESPONSE_PROCESS.md) encourages responsible disclosure
+- We are also available via [HackerOne](https://hackerone.com/monero)
+
## Build
| Operating System | Processor | Status |
diff --git a/VULNERABILITY_RESPONSE_PROCESS.md b/VULNERABILITY_RESPONSE_PROCESS.md
deleted file mode 100644
index eea3a06e7..000000000
--- a/VULNERABILITY_RESPONSE_PROCESS.md
+++ /dev/null
@@ -1,143 +0,0 @@
-# Monero Vulnerability Response Process
-
-## Preamble
-
-Researchers/Hackers: while you research/hack, we ask that you please refrain from committing the following:
-- Denial of Service / Active exploiting against the network
-- Social Engineering of Monero staff or contractors
-- Any physical or electronic attempts against Monero community property and/or data centers
-
-## I. Point of Contacts for Security Issues
-
-```
-ric@getmonero.org
-BDA6 BD70 42B7 21C4 67A9 759D 7455 C5E3 C0CD CEB9
-
-luigi1111@getmonero.org
-8777 AB8F 778E E894 87A2 F8E7 F4AC A018 3641 E010
-
-moneromooo.monero@gmail.com
-48B0 8161 FBDA DFE3 93AD FC3E 686F 0745 4D6C EFC3
-```
-
-## II. Security Response Team
-
-- fluffypony
-- luigi1111
-- moneromooo
-
-## III. Incident Response
-
-1. Researcher submits report via one or both of two methods:
- - a. Email
- - b. [HackerOne](https://hackerone.com/monero)
-
-2. Response Team designates a Response Manager who is in charge of the particular report based on availability and/or knowledge-set
-
-3. In no more than 3 working days, Response Team should gratefully respond to researcher using only encrypted, secure channels
-
-4. Response Manager makes inquiries to satisfy any needed information to confirm if submission is indeed a vulnerability
- - a. If submission proves to be vulnerable, proceed to next step
- - b. If not vulnerable:
- - i. Response Manager responds with reasons why submission is not a vulnerability
- - ii. Response Manager moves discussion to a new or existing ticket on GitHub if necessary
-
-5. If over email, Response Manager opens a HackerOne issue for new submission
-
-6. Establish severity of vulnerability:
- - a. HIGH: impacts network as a whole, has potential to break entire network, results in the loss of monero, or is on a scale of great catastrophe
- - b. MEDIUM: impacts individual nodes, wallets, or must be carefully exploited
- - c. LOW: is not easily exploitable
-
-7. Respond according to the severity of the vulnerability:
- - a. HIGH severities must be notified on website and reddit /r/Monero within 3 working days of classification
- - i. The notification should list appropriate steps for users to take, if any
- - ii. The notification must not include any details that could suggest an exploitation path
- - iii. The latter takes precedence over the former
- - b. MEDIUM and HIGH severities will require a Point Release
- - c. LOW severities will be addressed in the next Regular Release
-
-8. Response Team applies appropriate patch(es)
- - a. Response Manager designates a PRIVATE git "hotfix branch" to work in
- - b. Patches are reviewed with the researcher
- - c. Any messages associated with PUBLIC commits during the time of review should not make reference to the security nature of the PRIVATE branch or its commits
- - d. Vulnerability announcement is drafted
- - i. Include the severity of the vulnerability
- - ii. Include all vulnerable systems/apps/code
- - iii. Include solutions (if any) if patch cannot be applied
- - e. Release date is discussed
-
-9. At release date, Response Team coordinates with developers to finalize update:
- - a. Response Manager propagates the "hotfix branch" to trunk
- - b. Response Manager includes vulnerability announcement draft in release notes
- - c. Proceed with the Point or Regular Release
-
-## IV. Post-release Disclosure Process
-
-1. Response Team has 90 days to fulfill all points within section III
-
-2. If the Incident Response process in section III is successfully completed:
- - a. Response Manager contacts researcher and asks if researcher wishes for credit
- - b. Finalize vulnerability announcement draft and include the following:
- - i. Project name and URL
- - ii. Versions known to be affected
- - iii. Versions known to be not affected (for example, the vulnerable code was introduced in a recent version, and older versions are therefore unaffected)
- - iv. Versions not checked
- - v. Type of vulnerability and its impact
- - vi. If already obtained or applicable, a CVE-ID
- - vii. The planned, coordinated release date
- - viii. Mitigating factors (for example, the vulnerability is only exposed in uncommon, non-default configurations)
- - ix. Workarounds (configuration changes users can make to reduce their exposure to the vulnerability)
- - x. If applicable, credits to the original reporter
- - c. Release finalized vulnerability announcement on website and reddit /r/Monero
- - d. For HIGH severities, release finalized vulnerability announcement on well-known mailing lists:
- - i. oss-security@lists.openwall.com
- - ii. bugtraq@securityfocus.com
- - e. If applicable, developers request a CVE-ID
- - i. The commit that applied the fix is made reference too in a future commit and includes a CVE-ID
-
-3. If the Incident Response process in section III is *not* successfully completed:
- - a. Response Team and developers organize an IRC meeting to discuss why/what points in section III were not resolved and how the team can resolve them in the future
- - b. Any developer meetings immediately following the incident should include points made in section V
- - c. If disputes arise about whether or when to disclose information about a vulnerability, the Response Team will publicly discuss the issue via IRC and attempt to reach consensus
- - d. If consensus on a timely disclosure is not met (no later than 90 days), the researcher (after 90 days) has every right to expose the vulnerability to the public
-
-## V. Incident Analysis
-
-1. Isolate codebase
- - a. Response Team and developers should coordinate to work on the following:
- - i. Problematic implementation of classes/libraries/functions, etc.
- - ii. Focus on apps/distro packaging, etc.
- - iii. Operator/config error, etc.
-
-2. Auditing
- - a. Response Team and developers should coordinate to work on the following:
- - i. Auditing of problem area(s) as discussed in point 1
- - ii. Generate internal reports and store for future reference
- - iii. If results are not sensitive, share with the public via IRC or GitHub
-
-3. Response Team has 45 days following completion of section III to ensure completion of section V
-
-## VI. Resolutions
-
-Any further questions or resolutions regarding the incident(s) between the researcher and response + development team after public disclosure can be addressed via the following:
-
-- [GitHub](https://github.com/monero-project/monero/issues/)
-- [HackerOne](https://hackerone.com/monero)
-- [Reddit /r/Monero](https://reddit.com/r/Monero/)
-- IRC
-- Email
-
-## VII. Continuous Improvement
-
-1. Response Team and developers should hold annual meetings to review the previous year's incidents
-
-2. Response Team or designated person(s) should give a brief presentation, including:
- - a. Areas of Monero affected by the incidents
- - b. Any network downtime or monetary cost (if any) of the incidents
- - c. Ways in which the incidents could have been avoided (if any)
- - d. How effective this process was in dealing with the incidents
-
-3. After the presentation, Response Team and developers should discuss:
- - a. Potential changes to development processes to reduce future incidents
- - b. Potential changes to this process to improve future responses
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e3cb7cfd6..3e0bfb59c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -96,6 +96,9 @@ function (monero_add_library name)
PRIVATE $<TARGET_PROPERTY:${name},INTERFACE_COMPILE_DEFINITIONS>)
endfunction ()
+set_source_files_properties(${CMAKE_BINARY_DIR}/version.cpp PROPERTIES GENERATED ON)
+monero_add_library(version ${CMAKE_BINARY_DIR}/version.cpp)
+
add_subdirectory(common)
add_subdirectory(crypto)
add_subdirectory(ringct)
diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt
index ffdaad4af..0eaf71084 100644
--- a/src/blockchain_utilities/CMakeLists.txt
+++ b/src/blockchain_utilities/CMakeLists.txt
@@ -77,6 +77,7 @@ target_link_libraries(blockchain_import
cryptonote_core
blockchain_db
p2p
+ version
epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
@@ -89,8 +90,6 @@ if(ARCH_WIDTH)
PUBLIC -DARCH_WIDTH=${ARCH_WIDTH})
endif()
-add_dependencies(blockchain_import
- version)
set_property(TARGET blockchain_import
PROPERTY
OUTPUT_NAME "monero-blockchain-import")
@@ -104,6 +103,7 @@ target_link_libraries(blockchain_export
cryptonote_core
blockchain_db
p2p
+ version
epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
@@ -111,8 +111,6 @@ target_link_libraries(blockchain_export
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
-add_dependencies(blockchain_export
- version)
set_property(TARGET blockchain_export
PROPERTY
OUTPUT_NAME "monero-blockchain-export")
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 19d90253b..50887e35c 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -47,6 +47,7 @@ endif()
set(common_headers)
set(common_private_headers
+ apply_permutation.h
base58.h
boost_serialization_helper.h
command_line.h
diff --git a/src/common/apply_permutation.h b/src/common/apply_permutation.h
new file mode 100644
index 000000000..4fd952686
--- /dev/null
+++ b/src/common/apply_permutation.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2017, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Most of this file is originally copyright (c) 2017 Raymond Chen, Microsoft
+// This algorithm is adapted from Raymond Chen's code:
+// https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145
+
+#include <vector>
+#include <functional>
+#include "misc_log_ex.h"
+
+namespace tools
+{
+
+template<typename F>
+void apply_permutation(std::vector<size_t> permutation, const F &swap)
+{
+ //sanity check
+ for (size_t n = 0; n < permutation.size(); ++n)
+ CHECK_AND_ASSERT_THROW_MES(std::find(permutation.begin(), permutation.end(), n) != permutation.end(), "Bad permutation");
+
+ for (size_t i = 0; i < permutation.size(); ++i)
+ {
+ size_t current = i;
+ while (i != permutation[current])
+ {
+ size_t next = permutation[current];
+ swap(current, next);
+ permutation[current] = current;
+ current = next;
+ }
+ permutation[current] = current;
+ }
+}
+
+template<typename T>
+void apply_permutation(const std::vector<size_t> &permutation, std::vector<T> &v)
+{
+ CHECK_AND_ASSERT_THROW_MES(permutation.size() == v.size(), "Mismatched vector sizes");
+ apply_permutation(permutation, [&v](size_t i0, size_t i1){ std::swap(v[i0], v[i1]); });
+}
+
+}
diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt
index 7c43323d4..7b73eebd1 100644
--- a/src/cryptonote_core/CMakeLists.txt
+++ b/src/cryptonote_core/CMakeLists.txt
@@ -55,6 +55,7 @@ monero_add_library(cryptonote_core
${cryptonote_core_private_headers})
target_link_libraries(cryptonote_core
PUBLIC
+ version
common
cncrypto
blockchain_db
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 274c8cd07..7ee88e430 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2384,6 +2384,26 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context
}
}
+ // from v7, sorted outs
+ if (m_hardfork->get_current_version() >= 7) {
+ const crypto::public_key *last_key = NULL;
+ for (size_t n = 0; n < tx.vout.size(); ++n)
+ {
+ const tx_out &o = tx.vout[n];
+ if (o.target.type() == typeid(txout_to_key))
+ {
+ const txout_to_key& out_to_key = boost::get<txout_to_key>(o.target);
+ if (last_key && memcmp(&out_to_key.key, last_key, sizeof(*last_key)) >= 0)
+ {
+ MERROR_VER("transaction has unsorted outputs");
+ tvc.m_invalid_output = true;
+ return false;
+ }
+ last_key = &out_to_key.key;
+ }
+ }
+ }
+
return true;
}
//------------------------------------------------------------------
@@ -2552,6 +2572,25 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
}
}
+ // from v7, sorted ins
+ if (hf_version >= 7) {
+ const crypto::key_image *last_key_image = NULL;
+ for (size_t n = 0; n < tx.vin.size(); ++n)
+ {
+ const txin_v &txin = tx.vin[n];
+ if (txin.type() == typeid(txin_to_key))
+ {
+ const txin_to_key& in_to_key = boost::get<txin_to_key>(txin);
+ if (last_key_image && memcmp(&in_to_key.k_image, last_key_image, sizeof(*last_key_image)) >= 0)
+ {
+ MERROR_VER("transaction has unsorted inputs");
+ tvc.m_verifivation_failed = true;
+ return false;
+ }
+ last_key_image = &in_to_key.k_image;
+ }
+ }
+ }
auto it = m_check_txin_table.find(tx_prefix_hash);
if(it == m_check_txin_table.end())
{
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 258119566..d2a7eedf5 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -31,6 +31,7 @@
#include "include_base_utils.h"
using namespace epee;
+#include "common/apply_permutation.h"
#include "cryptonote_tx_utils.h"
#include "cryptonote_config.h"
#include "cryptonote_basic/miner.h"
@@ -156,7 +157,7 @@ namespace cryptonote
return destinations[0].addr.m_view_public_key;
}
//---------------------------------------------------------------
- bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct)
+ bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry> sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct)
{
std::vector<rct::key> amount_keys;
tx.set_null();
@@ -263,14 +264,25 @@ namespace cryptonote
tx.vin.push_back(input_to_key);
}
- // "Shuffle" outs
- std::vector<tx_destination_entry> shuffled_dsts(destinations);
- std::random_shuffle(shuffled_dsts.begin(), shuffled_dsts.end(), [](unsigned int i) { return crypto::rand<unsigned int>() % i; });
+ // sort ins by their key image
+ std::vector<size_t> ins_order(sources.size());
+ for (size_t n = 0; n < sources.size(); ++n)
+ ins_order[n] = n;
+ std::sort(ins_order.begin(), ins_order.end(), [&](const size_t i0, const size_t i1) {
+ const txin_to_key &tk0 = boost::get<txin_to_key>(tx.vin[i0]);
+ const txin_to_key &tk1 = boost::get<txin_to_key>(tx.vin[i1]);
+ return memcmp(&tk0.k_image, &tk1.k_image, sizeof(tk0.k_image)) < 0;
+ });
+ tools::apply_permutation(ins_order, [&] (size_t i0, size_t i1) {
+ std::swap(tx.vin[i0], tx.vin[i1]);
+ std::swap(in_contexts[i0], in_contexts[i1]);
+ std::swap(sources[i0], sources[i1]);
+ });
uint64_t summary_outs_money = 0;
//fill outputs
size_t output_index = 0;
- for(const tx_destination_entry& dst_entr: shuffled_dsts)
+ for(const tx_destination_entry& dst_entr: destinations)
{
CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount);
crypto::key_derivation derivation;
@@ -297,6 +309,20 @@ namespace cryptonote
summary_outs_money += dst_entr.amount;
}
+ // sort outs by their public key
+ std::vector<size_t> outs_order(tx.vout.size());
+ for (size_t n = 0; n < tx.vout.size(); ++n)
+ outs_order[n] = n;
+ std::sort(outs_order.begin(), outs_order.end(), [&](size_t i0, size_t i1) {
+ const txout_to_key &tk0 = boost::get<txout_to_key>(tx.vout[i0].target);
+ const txout_to_key &tk1 = boost::get<txout_to_key>(tx.vout[i1].target);
+ return memcmp(&tk0.key, &tk1.key, sizeof(tk0.key)) < 0;
+ });
+ tools::apply_permutation(outs_order, [&] (size_t i0, size_t i1) {
+ std::swap(tx.vout[i0], tx.vout[i1]);
+ std::swap(amount_keys[i0], amount_keys[i1]);
+ });
+
//check money
if(summary_outs_money > summary_inputs_money )
{
diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h
index 7aa7c280d..69254fb5f 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.h
+++ b/src/cryptonote_core/cryptonote_tx_utils.h
@@ -71,7 +71,7 @@ namespace cryptonote
//---------------------------------------------------------------
crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const account_keys &sender_keys);
bool construct_tx(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time);
- bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false);
+ bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry> sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false);
bool generate_genesis_block(
block& bl
diff --git a/src/cryptonote_protocol/CMakeLists.txt b/src/cryptonote_protocol/CMakeLists.txt
index 4ce380a48..347e48eee 100644
--- a/src/cryptonote_protocol/CMakeLists.txt
+++ b/src/cryptonote_protocol/CMakeLists.txt
@@ -39,5 +39,3 @@ target_link_libraries(cryptonote_protocol
p2p
PRIVATE
${EXTRA_LIBRARIES})
-add_dependencies(cryptonote_protocol
- version)
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 782667867..d0fc1d846 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -94,6 +94,7 @@ target_link_libraries(daemon
daemonizer
serialization
daemon_rpc_server
+ version
${Boost_CHRONO_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
@@ -102,7 +103,6 @@ target_link_libraries(daemon
${CMAKE_THREAD_LIBS_INIT}
${ZMQ_LIB}
${EXTRA_LIBRARIES})
-add_dependencies(daemon version)
set_property(TARGET daemon
PROPERTY
OUTPUT_NAME "monerod")
diff --git a/src/debug_utilities/CMakeLists.txt b/src/debug_utilities/CMakeLists.txt
index 99198dc57..7a82c12d9 100644
--- a/src/debug_utilities/CMakeLists.txt
+++ b/src/debug_utilities/CMakeLists.txt
@@ -42,8 +42,6 @@ target_link_libraries(cn_deserialize
epee
${CMAKE_THREAD_LIBS_INIT})
-add_dependencies(cn_deserialize
- version)
set_property(TARGET cn_deserialize
PROPERTY
OUTPUT_NAME "monero-utils-deserialize")
@@ -65,8 +63,6 @@ target_link_libraries(object_sizes
epee
${CMAKE_THREAD_LIBS_INIT})
-add_dependencies(object_sizes
- version)
set_property(TARGET object_sizes
PROPERTY
OUTPUT_NAME "monero-utils-object-sizes")
diff --git a/src/p2p/CMakeLists.txt b/src/p2p/CMakeLists.txt
index 0704940b5..2e34db5d1 100644
--- a/src/p2p/CMakeLists.txt
+++ b/src/p2p/CMakeLists.txt
@@ -47,5 +47,3 @@ target_link_libraries(p2p
${Boost_THREAD_LIBRARY}
PRIVATE
${EXTRA_LIBRARIES})
-add_dependencies(p2p
- version)
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 7da123633..f1ca50f76 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -1916,6 +1916,8 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::gray_peerlist_housekeeping()
{
+ if (!m_exclusive_peers.empty()) return true;
+
peerlist_entry pe = AUTO_VAL_INIT(pe);
if (m_net_server.is_stop_signal_sent())
diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt
index b5c38b1a8..23bb6aaae 100644
--- a/src/rpc/CMakeLists.txt
+++ b/src/rpc/CMakeLists.txt
@@ -117,10 +117,3 @@ target_link_libraries(daemon_rpc_server
${EXTRA_LIBRARIES})
target_include_directories(daemon_rpc_server PUBLIC ${ZMQ_INCLUDE_PATH})
target_include_directories(obj_daemon_rpc_server PUBLIC ${ZMQ_INCLUDE_PATH})
-
-
-add_dependencies(rpc
- version)
-
-add_dependencies(daemon_rpc_server
- version)
diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt
index 443e9b87e..b56085b8f 100644
--- a/src/simplewallet/CMakeLists.txt
+++ b/src/simplewallet/CMakeLists.txt
@@ -49,14 +49,13 @@ target_link_libraries(simplewallet
common
mnemonics
p2p
+ version
${Boost_CHRONO_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
-add_dependencies(simplewallet
- version)
set_property(TARGET simplewallet
PROPERTY
OUTPUT_NAME "monero-wallet-cli")
diff --git a/src/version.cmake b/src/version.cmake
index 623d3cf1f..45a97cd20 100644
--- a/src/version.cmake
+++ b/src/version.cmake
@@ -36,7 +36,7 @@ if(RET)
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
set(VERSIONTAG "unknown")
- configure_file("src/version.h.in" "${TO}")
+ configure_file("src/version.cpp.in" "${TO}")
else()
message(STATUS "You are currently on commit ${COMMIT}")
@@ -59,5 +59,5 @@ else()
endif()
endif()
- configure_file("src/version.h.in" "${TO}")
+ configure_file("src/version.cpp.in" "${TO}")
endif()
diff --git a/src/version.cpp.in b/src/version.cpp.in
new file mode 100644
index 000000000..320a8d58a
--- /dev/null
+++ b/src/version.cpp.in
@@ -0,0 +1,9 @@
+#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
+#define DEF_MONERO_VERSION "0.11.0.0"
+#define DEF_MONERO_RELEASE_NAME "Helium Hydra"
+#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
+
+const char* const MONERO_VERSION_TAG = DEF_MONERO_VERSION_TAG;
+const char* const MONERO_VERSION = DEF_MONERO_VERSION;
+const char* const MONERO_RELEASE_NAME = DEF_MONERO_RELEASE_NAME;
+const char* const MONERO_VERSION_FULL = DEF_MONERO_VERSION_FULL;
diff --git a/src/version.h b/src/version.h
new file mode 100644
index 000000000..d1d06c790
--- /dev/null
+++ b/src/version.h
@@ -0,0 +1,6 @@
+#pragma once
+
+extern const char* const MONERO_VERSION_TAG;
+extern const char* const MONERO_VERSION;
+extern const char* const MONERO_RELEASE_NAME;
+extern const char* const MONERO_VERSION_FULL;
diff --git a/src/version.h.in b/src/version.h.in
deleted file mode 100644
index 281b52db4..000000000
--- a/src/version.h.in
+++ /dev/null
@@ -1,4 +0,0 @@
-#define MONERO_VERSION_TAG "@VERSIONTAG@"
-#define MONERO_VERSION "0.11.0.0"
-#define MONERO_RELEASE_NAME "Helium Hydra"
-#define MONERO_VERSION_FULL MONERO_VERSION "-" MONERO_VERSION_TAG
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index 639080051..fe87d0de1 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -84,7 +84,6 @@ target_link_libraries(wallet
${Boost_REGEX_LIBRARY}
PRIVATE
${EXTRA_LIBRARIES})
-add_dependencies(wallet version)
if (NOT BUILD_GUI_DEPS)
set(wallet_rpc_sources
@@ -110,13 +109,13 @@ if (NOT BUILD_GUI_DEPS)
cryptonote_core
cncrypto
common
+ version
${Boost_CHRONO_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
- add_dependencies(wallet_rpc_server version)
set_property(TARGET wallet_rpc_server
PROPERTY
OUTPUT_NAME "monero-wallet-rpc")
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 6339ce241..cb35482bd 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1545,7 +1545,7 @@ namespace tools
er.message = "Failed to add address book entry";
return false;
}
- res.index = m_wallet->get_address_book().size();
+ res.index = m_wallet->get_address_book().size() - 1;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
diff --git a/tests/core_proxy/CMakeLists.txt b/tests/core_proxy/CMakeLists.txt
index d22fecc9c..d2dc93cf0 100644
--- a/tests/core_proxy/CMakeLists.txt
+++ b/tests/core_proxy/CMakeLists.txt
@@ -40,6 +40,7 @@ target_link_libraries(core_proxy
cryptonote_core
cryptonote_protocol
p2p
+ version
epee
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt
index c1d3161bc..a24bd4fce 100644
--- a/tests/core_tests/CMakeLists.txt
+++ b/tests/core_tests/CMakeLists.txt
@@ -65,6 +65,7 @@ target_link_libraries(coretests
PRIVATE
cryptonote_core
p2p
+ version
epee
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt
index 51375440b..4c5542d91 100644
--- a/tests/libwallet_api_tests/CMakeLists.txt
+++ b/tests/libwallet_api_tests/CMakeLists.txt
@@ -40,6 +40,7 @@ add_executable(libwallet_api_tests
target_link_libraries(libwallet_api_tests
PRIVATE
wallet
+ version
epee
${Boost_CHRONO_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
index f5e08b102..63abe928d 100644
--- a/tests/unit_tests/CMakeLists.txt
+++ b/tests/unit_tests/CMakeLists.txt
@@ -27,6 +27,7 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set(unit_tests_sources
+ apply_permutation.cpp
address_from_url.cpp
ban.cpp
base58.cpp
@@ -78,6 +79,7 @@ target_link_libraries(unit_tests
rpc
wallet
p2p
+ version
epee
${Boost_CHRONO_LIBRARY}
${Boost_THREAD_LIBRARY}
diff --git a/tests/unit_tests/apply_permutation.cpp b/tests/unit_tests/apply_permutation.cpp
new file mode 100644
index 000000000..a008b74ee
--- /dev/null
+++ b/tests/unit_tests/apply_permutation.cpp
@@ -0,0 +1,74 @@
+// Copyright (c) 2017, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "gtest/gtest.h"
+#include "common/apply_permutation.h"
+
+TEST(apply_permutation, empty)
+{
+ std::vector<int> v = {};
+ tools::apply_permutation({}, v);
+ ASSERT_EQ(v, std::vector<int>({}));
+}
+
+TEST(apply_permutation, reorder)
+{
+ // 0 1 2 3 4 5 6
+ std::vector<int> v = {8, 4, 6, 1, 7, 2, 4};
+ tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v);
+ ASSERT_EQ(v, std::vector<int>({1, 2, 4, 4, 6, 7, 8}));
+}
+
+TEST(apply_permutation, bad_size)
+{
+ std::vector<int> v_large = {8, 4, 6, 1, 7, 2, 4, 9};
+ std::vector<int> v_small = {8, 4, 6, 1, 7, 2};
+ try
+ {
+ tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_large);
+ ASSERT_FALSE(true);
+ }
+ catch (const std::exception &e) {}
+ try
+ {
+ tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_small);
+ ASSERT_FALSE(true);
+ }
+ catch (const std::exception &e) {}
+}
+
+TEST(apply_permutation, bad_permutation)
+{
+ std::vector<int> v = {8, 4, 6, 1, 7, 2, 4};
+ try
+ {
+ tools::apply_permutation({3, 5, 6, 1, 2, 4, 1}, v);
+ ASSERT_FALSE(true);
+ }
+ catch (const std::exception &e) {}
+}
diff --git a/utils/systemd/monerod.service b/utils/systemd/monerod.service
index 12395eb8c..96e88a2d3 100644
--- a/utils/systemd/monerod.service
+++ b/utils/systemd/monerod.service
@@ -6,12 +6,13 @@ After=network.target
User=monero
Group=monero
WorkingDirectory=~
+RuntimeDirectory=monero
Type=forking
-PIDFile=/var/run/monerod.pid
+PIDFile=/run/monero/monerod.pid
ExecStart=/usr/bin/monerod --config-file /etc/monerod.conf \
- --detach --pidfile /var/run/monerod.pid
+ --detach --pidfile /run/monero/monerod.pid
[Install]
WantedBy=multi-user.target
diff --git a/version.cmake b/version.cmake
index 80f1c40b8..75343c381 100644
--- a/version.cmake
+++ b/version.cmake
@@ -1,32 +1,49 @@
+# Copyright (c) 2014-2017, The Monero Project
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other
+# materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be
+# used to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
function (write_static_version_header hash)
set(VERSIONTAG "${hash}")
- configure_file("src/version.h.in" "version/version.h")
- add_custom_target(version ALL)
+ configure_file("src/version.cpp.in" "version.cpp")
endfunction ()
-file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
find_package(Git QUIET)
if ("$Format:$" STREQUAL "")
# We're in a tarball; use hard-coded variables.
write_static_version_header("release")
elseif (GIT_FOUND OR Git_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
- set(extra_output)
- if (CMAKE_GENERATOR MATCHES "Ninja")
- # Ninja will not rerun the command every time if the file doesn't change,
- # so inject this bogus output so that it always runs.
- set(extra_output "${CMAKE_SOURCE_DIR}/.force-git-version-check")
- endif ()
- add_custom_command(
- OUTPUT "${CMAKE_BINARY_DIR}/version/version.h"
- ${extra_output}
+ add_custom_target(genversion ALL
COMMAND "${CMAKE_COMMAND}"
"-D" "GIT=${GIT_EXECUTABLE}"
- "-D" "TO=${CMAKE_BINARY_DIR}/version/version.h"
+ "-D" "TO=${CMAKE_BINARY_DIR}/version.cpp"
"-P" "src/version.cmake"
+ BYPRODUCTS "${CMAKE_BINARY_DIR}/version.cpp"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
- add_custom_target(version ALL
- DEPENDS "${CMAKE_BINARY_DIR}/version/version.h")
else()
message(STATUS "WARNING: Git was not found!")
write_static_version_header("unknown")