mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #13197: util: warn about ignored recursive -includeconf calls
2352aa9 test: Ensure that recursive -includeconf produces appropriate warnings (Karl-Johan Alm) c5bcc7d util: warn about recursive -includeconf arguments in configuration files (Karl-Johan Alm) Pull request description: This is a follow-up PR to #10267, and addresses https://github.com/bitcoin/bitcoin/pull/10267#issuecomment-387546144. ~~I am adding extra work for @jnewbery in #12755 here -- maybe I should just rebase on top of that, but not sure what the appropriate approach is here.~~ Tree-SHA512: 87f0c32436b70424e33616ffb88d7cb699f90d6a583a10237e224b28fc936d6a9df95536c8c52ee8546b3942da92b2a357e61bf87e00d1462bc10d46d3bee352
This commit is contained in:
parent
13300e413a
commit
ec9f526cec
@ -824,6 +824,14 @@ void ArgsManager::ReadConfigFiles()
|
||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
|
||||
}
|
||||
|
||||
// Remove -includeconf from configuration, so we can warn about recursion
|
||||
// later
|
||||
{
|
||||
LOCK(cs_args);
|
||||
m_config_args.erase("-includeconf");
|
||||
m_config_args.erase(std::string("-") + GetChainName() + ".includeconf");
|
||||
}
|
||||
|
||||
for (const std::string& to_include : includeconf) {
|
||||
fsbridge::ifstream include_config(GetConfigFile(to_include));
|
||||
if (include_config.good()) {
|
||||
@ -833,6 +841,16 @@ void ArgsManager::ReadConfigFiles()
|
||||
fprintf(stderr, "Failed to include configuration file %s\n", to_include.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Warn about recursive -includeconf
|
||||
includeconf = GetArgs("-includeconf");
|
||||
{
|
||||
std::vector<std::string> includeconf_net(GetArgs(std::string("-") + GetChainName() + ".includeconf"));
|
||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
|
||||
}
|
||||
for (const std::string& to_include : includeconf) {
|
||||
fprintf(stderr, "warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n", to_include.c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create an empty dash.conf if it does not exist
|
||||
|
@ -53,11 +53,11 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||
self.log.info("-includeconf cannot be used recursively. subversion should end with 'main; relative)/'")
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "a", encoding="utf8") as f:
|
||||
f.write("includeconf=relative2.conf\n")
|
||||
|
||||
self.start_node(0)
|
||||
|
||||
subversion = self.nodes[0].getnetworkinfo()["subversion"]
|
||||
assert subversion.endswith("main; relative)/")
|
||||
self.stop_node(0, expected_stderr="warning: -includeconf cannot be used from included files; ignoring -includeconf=relative2.conf")
|
||||
|
||||
self.log.info("multiple -includeconf args can be used from the base config file. subversion should end with 'main; relative; relative2)/'")
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f:
|
||||
@ -66,7 +66,7 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "dash.conf"), "a", encoding='utf8') as f:
|
||||
f.write("includeconf=relative2.conf\n")
|
||||
|
||||
self.restart_node(0)
|
||||
self.start_node(0)
|
||||
|
||||
subversion = self.nodes[0].getnetworkinfo()["subversion"]
|
||||
assert subversion.endswith("main; relative; relative2)/")
|
||||
|
Loading…
Reference in New Issue
Block a user