diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -994,6 +994,15 @@ 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()) { @@ -1008,6 +1017,21 @@ to_include.c_str()); } } + + // Warn about recursive -includeconf + includeconf = GetArgs("-includeconf"); + { + std::vector 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()); + } } } diff --git a/test/functional/feature_includeconf.py b/test/functional/feature_includeconf.py --- a/test/functional/feature_includeconf.py +++ b/test/functional/feature_includeconf.py @@ -58,11 +58,12 @@ "-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)/'") @@ -72,7 +73,7 @@ with open(os.path.join(self.options.tmpdir, "node0", "bitcoin.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)/")