util: warn about recursive -includeconf arguments in configuration files
Since -includeconf cannot be used recursively, the user would not see feedback that an -includeconf in an -includeconf'd file was silently ignored.
This commit is contained in:
parent
196c5a947a
commit
c5bcc7dbe9
1 changed files with 18 additions and 0 deletions
18
src/util.cpp
18
src/util.cpp
|
@ -790,6 +790,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) {
|
||||
fs::ifstream include_config(GetConfigFile(to_include));
|
||||
if (include_config.good()) {
|
||||
|
@ -799,6 +807,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue