Skip to content

Commit 5e744f4

Browse files
committed
util: disallow setting conf in bitcoin.conf
Help from `bitcoind -h` states that conf can only be used from the commandline. However, if conf is set in a bitcoin.conf file, it is ignored but there is no error. Show an error to user if conf is set in a .conf file and prompt them to use `includeconf` if they wish to specify additional config files. Adds `IsConfSupported` function to allow for easily adding conf options to disallow or throw warnings for.
1 parent 73b6171 commit 5e744f4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/util/system.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,14 @@ static bool GetConfigOptions(std::istream& stream, const std::string& filepath,
935935
return true;
936936
}
937937

938+
bool IsConfSupported(KeyInfo& key, std::string& error) {
939+
if (key.name == "conf") {
940+
error = "conf cannot be set in the configuration file; use includeconf= if you want to include additional config files";
941+
return false;
942+
}
943+
return true;
944+
}
945+
938946
bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys)
939947
{
940948
LOCK(cs_args);
@@ -945,6 +953,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
945953
for (const std::pair<std::string, std::string>& option : options) {
946954
KeyInfo key = InterpretKey(option.first);
947955
std::optional<unsigned int> flags = GetArgFlags('-' + key.name);
956+
if (!IsConfSupported(key, error)) return false;
948957
if (flags) {
949958
std::optional<util::SettingsValue> value = InterpretValue(key, &option.second, *flags, error);
950959
if (!value) {

0 commit comments

Comments
 (0)