aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-07-31 12:17:43 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-07-31 12:17:55 -0400
commit230652cafc51a087b25a5e6fbc0114e63b3be0aa (patch)
treea9cc69b1837270f027b3620312ce7b0cbc9cc5b8
parent77168f766f15c6621fb2af0dfcf2dd12b971172c (diff)
parent247d5740d29752c35861136a2fc561831c7e9832 (diff)
downloadbitcoin-230652cafc51a087b25a5e6fbc0114e63b3be0aa.tar.xz
Merge #13799: Ignore unknown config file options; warn instead of error
247d5740d2 Ignore unknown config file options for now (Pieter Wuille) 04ce0d88ca Report when unknown config file options are ignored (Pieter Wuille) Pull request description: As reported by @satwo on IRC a few days ago, the current mechanism of treating unknown config file options as errors is problematic for options like `-rpcclienttimeout` which aren't defined for `bitcoind`. A full solution would be to either make all binaries be aware of each other's options, or to permit config file options that only apply to specific binaries (`bitcoind`, `bitcoin-qt`, `bitcoin-cli`). Both of these seem too invasive to introduce for 0.17. As a compromise, this PR makes it ignores those options, but still warn about it in the log file. Tree-SHA512: dfddc771b91df3031a9c98d9f3292f8f4fcd1b97ebb7317b2f457e12d9f205dc63f42721302e7258dbb53f273d7cc041a65a0a9120972769555784e1f1cc9aef
-rw-r--r--src/bitcoind.cpp2
-rw-r--r--src/interfaces/node.cpp2
-rw-r--r--src/util.cpp10
-rwxr-xr-xtest/functional/feature_includeconf.py8
4 files changed, 14 insertions, 8 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 5c711c0773..4d010c0d14 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -96,7 +96,7 @@ static bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return false;
}
- if (!gArgs.ReadConfigFiles(error)) {
+ if (!gArgs.ReadConfigFiles(error, true)) {
fprintf(stderr, "Error reading configuration file: %s\n", error.c_str());
return false;
}
diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp
index db371d104e..106dd38f60 100644
--- a/src/interfaces/node.cpp
+++ b/src/interfaces/node.cpp
@@ -53,7 +53,7 @@ class NodeImpl : public Node
{
return gArgs.ParseParameters(argc, argv, error);
}
- bool readConfigFiles(std::string& error) override { return gArgs.ReadConfigFiles(error); }
+ bool readConfigFiles(std::string& error) override { return gArgs.ReadConfigFiles(error, true); }
bool softSetArg(const std::string& arg, const std::string& value) override { return gArgs.SoftSetArg(arg, value); }
bool softSetBoolArg(const std::string& arg, bool value) override { return gArgs.SoftSetBoolArg(arg, value); }
void selectParams(const std::string& network) override { SelectParams(network); }
diff --git a/src/util.cpp b/src/util.cpp
index 2f81f50a71..238554ee4a 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -859,9 +859,13 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
}
// Check that the arg is known
- if (!IsArgKnown(strKey) && !ignore_invalid_keys) {
- error = strprintf("Invalid configuration value %s", option.first.c_str());
- return false;
+ if (!IsArgKnown(strKey)) {
+ if (!ignore_invalid_keys) {
+ error = strprintf("Invalid configuration value %s", option.first.c_str());
+ return false;
+ } else {
+ LogPrintf("Ignoring unknown configuration value %s\n", option.first);
+ }
}
}
return true;
diff --git a/test/functional/feature_includeconf.py b/test/functional/feature_includeconf.py
index 9a7a0ca103..d06f6826f0 100755
--- a/test/functional/feature_includeconf.py
+++ b/test/functional/feature_includeconf.py
@@ -55,9 +55,11 @@ class IncludeConfTest(BitcoinTestFramework):
self.stop_node(0, expected_stderr="warning: -includeconf cannot be used from included files; ignoring -includeconf=relative2.conf")
self.log.info("-includeconf cannot contain invalid arg")
- with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f:
- f.write("foo=bar\n")
- self.nodes[0].assert_start_raises_init_error(expected_msg="Error reading configuration file: Invalid configuration value foo")
+
+ # Commented out as long as we ignore invalid arguments in configuration files
+ #with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f:
+ # f.write("foo=bar\n")
+ #self.nodes[0].assert_start_raises_init_error(expected_msg="Error reading configuration file: Invalid configuration value foo")
self.log.info("-includeconf cannot be invalid path")
os.remove(os.path.join(self.options.tmpdir, "node0", "relative.conf"))