Skip to content

Commit

Permalink
fixup! Don't allow relative -walletdir paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanofsky committed Jan 18, 2018
1 parent b84b0dd commit 46c40bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ bool AppInit(int argc, char* argv[])
return false;
#endif // HAVE_DECL_DAEMON
}
// 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());
}
// Lock data directory after daemonization
if (!AppInitLockDataDirectory())
{
Expand Down
9 changes: 9 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fs::path GetWalletDir()
fs::path path;

if (gArgs.IsArgSet("-walletdir")) {
path = fs::system_complete(gArgs.GetArg("-walletdir", ""));
path = gArgs.GetArg("-walletdir", "");
if (!fs::is_directory(path)) {
// If the path specified doesn't exist, we return the deliberately
// invalid empty string.
Expand Down

0 comments on commit 46c40bf

Please sign in to comment.