diff options
| author | Russell Yanofsky <[email protected]> | 2018-01-18 13:15:00 -0500 |
|---|---|---|
| committer | Russell Yanofsky <[email protected]> | 2018-01-18 15:09:27 -0500 |
| commit | ec527c6c88146d5b36de38a1fcebe4f6ea72bd1b (patch) | |
| tree | 6413ebc3e95bd2925a2963299dbfddf360b56329 /src/wallet/init.cpp | |
| parent | Merge #12166: [docs] Clarify -walletdir usage (diff) | |
| download | discoin-ec527c6c88146d5b36de38a1fcebe4f6ea72bd1b.tar.xz discoin-ec527c6c88146d5b36de38a1fcebe4f6ea72bd1b.zip | |
Don't allow relative -walletdir paths
Also warn if bitcoind is configured to use a relative -datadir path.
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 also 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.
Diffstat (limited to 'src/wallet/init.cpp')
| -rw-r--r-- | src/wallet/init.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 0f453f154..2d26f7ae0 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -205,11 +205,15 @@ bool VerifyWallets() return true; } - if (gArgs.IsArgSet("-walletdir") && !fs::is_directory(GetWalletDir())) { - if (fs::exists(fs::system_complete(gArgs.GetArg("-walletdir", "")))) { - return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), gArgs.GetArg("-walletdir", "").c_str())); + if (gArgs.IsArgSet("-walletdir")) { + fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); + if (!fs::exists(wallet_dir)) { + return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), wallet_dir.string())); + } else if (!fs::is_directory(wallet_dir)) { + return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), wallet_dir.string())); + } else if (!wallet_dir.is_absolute()) { + return InitError(strprintf(_("Specified -walletdir \"%s\" is a relative path"), wallet_dir.string())); } - return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), gArgs.GetArg("-walletdir", "").c_str())); } LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); |