diff options
| author | Wladimir J. van der Laan <[email protected]> | 2018-01-19 17:44:27 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2018-01-19 17:46:17 +0100 |
| commit | f4c942e3615435c9e5d7ff0cefd935be08768d0c (patch) | |
| tree | fb8d7b36d94846595de88fae91df70ec1edc8b89 /src/init.cpp | |
| parent | Merge #12212: Trivial: Fix spelling in zapwallettxes test description (diff) | |
| parent | Don't allow relative -walletdir paths (diff) | |
| download | discoin-f4c942e3615435c9e5d7ff0cefd935be08768d0c.tar.xz discoin-f4c942e3615435c9e5d7ff0cefd935be08768d0c.zip | |
Merge #12220: Error if relative -walletdir is specified
ec527c6 Don't allow relative -walletdir paths (Russell Yanofsky)
Pull request description:
This makes it an error to explicitly specify a non-absolute -walletdir path, and also adds a debug.log warning if a relative rather than absolute -datadir path is configured.
Specifying paths relative to the current working directory in a daemon process can be dangerous, because files can fail to be located even if the configuration doesn't change, but the daemon is started up differently.
Specifying a relative -datadir now adds a warning to the debug log. It would not be backwards-compatible to forbid relative -datadir paths entirely, and it could also be inconvenient for command line testing.
Specifying a relative -walletdir now results in a startup error. But since the -walletdir option is new in 0.16.0, there should be no compatibility issues. Another reason not to use working directory paths for -walletdir specifically is that the default -walletdir is a "wallets" subdirectory inside the datadir, so it could be surprising that setting -walletdir manually would choose a directory rooted in a completely different location.
Tree-SHA512: 67cbdae677f82487a9031c5ec96b0205a488ab08718a0f4f49365e025119f3d7f6cfc88ba1eba04c1ecd8b9561a5b2c42e2e1a267af7c08c76b83e5e361f5a31
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp index b48802637..d1d733af9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1210,6 +1210,15 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("Using config file %s\n", GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string()); LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); + // Warn about relative -datadir path. + if (gArgs.IsArgSet("-datadir") && !fs::path(gArgs.GetArg("-datadir", "")).is_absolute()) { + LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " + "current working directory '%s'. This is fragile, because if bitcoin is started in the future " + "from a different location, it will be unable to locate the current data files. There could " + "also be data loss if bitcoin is started while in a temporary directory.\n", + gArgs.GetArg("-datadir", ""), fs::current_path().string()); + } + InitSignatureCache(); InitScriptExecutionCache(); |