diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2023-03-27 10:17:57 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2023-04-21 06:53:23 -0400 |
commit | eefe56967b4eb4b5144325cde4f40fc1cbde3e65 (patch) | |
tree | ab920af1fd1aef8f6465ee25c730ab6d9b151178 /src/common/init.cpp | |
parent | 3746f00be1b732a04976fc70cbb0661f97bbbd99 (diff) |
bugfix: Fix incorrect debug.log config file path
Currently debug.log will show the wrong bitcoin.conf config file path when
bitcoind is invoked without -conf or -datadir arguments, and there's a default
bitcoin.conf file which specifies another datadir= location. When this happens,
the debug.log will include an incorrect "Config file:" line referring to a
bitcoin.conf file in the other datadir, instead of the referring to the actual
configuration file in the default datadir which was parsed.
The bad log print was reported and originally fixed in
https://github.com/bitcoin/bitcoin/pull/27303 by
Matthew Zipkin <pinheadmz@gmail.com>
This PR takes a slightly different approach to fixing the bug, trying to avoid
future bugs by not allowing the GetConfigFilePath function to be called before
the the configuration is parsed, and deleting GetConfigFile function which
could be confused with GetConfigFilePath. It also includes a test for the bug
which the original fix did not have.
Co-authored-by: Matthew Zipkin <pinheadmz@gmail.com>
Diffstat (limited to 'src/common/init.cpp')
-rw-r--r-- | src/common/init.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/init.cpp b/src/common/init.cpp index 60df14de9a..f5a412b1a1 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -32,7 +32,7 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting // parse error, and specifying a datadir= location containing another // bitcoin.conf file just ignores the other file.) const fs::path orig_datadir_path{args.GetDataDirBase()}; - const fs::path orig_config_path = args.GetConfigFilePath(); + const fs::path orig_config_path{AbsPathForConfigVal(args, args.GetPathArg("-conf", BITCOIN_CONF_FILENAME), /*net_specific=*/false)}; std::string error; if (!args.ReadConfigFiles(error, true)) { |