mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge bitcoin/bitcoin#30401: fix: increase consistency of rpcauth parsing
27c976d11afix: increase consistency of rpcauth parsing (tdb3)2ad3689512test: add norpcauth test (tdb3)67df0dec1atest: blank rpcauth CLI interaction (tdb3)ecc98ccff2test: add cases for blank rpcauth (tdb3) Pull request description: The current `rpcauth` parsing behavior is inconsistent and unintuitive (see https://github.com/bitcoin/bitcoin/pull/29141#issuecomment-1972085251 and additional details below). The current behavior inconsistently treats empty `rpcauth` as an error (or not) depending on the location within CLI/bitcoin.conf and the location of adjacent valid `rpcauth` params. Empty `rpcauth` is now consistently treated as an error and prevents bitcoind from starting. Continuation of the upforgrabs PR #29141. ### Additional details: Current `rpcauth` behavior is nonsensical: - If an empty `rpcauth` argument was specified as the last command line argument, it would cause all other `rpcauth` arguments to be ignored. - If an empty `rpcauth` argument was specified on the command line followed by any nonempty `rpcauth` argument, it would cause an error. - If an empty `rpcauth=` line was specified after non-empty rpcauth line in the config file it would cause an error. - If an empty `rpcauth=` line in a config file was first it would cause other rpcauth entries in the config file to be ignored, unless there were `-rpcauth` command line arguments and the last one was nonempty, in which case it would cause an error. New behavior is simple: - If an empty rpcauth config line or command line argument is used it will cause an error ACKs for top commit: naiyoma: Tested ACK [27c976d11a) achow101: ACK27c976d11aryanofsky: Code review ACK27c976d11a. Since last review commit message was just tweaked to clarify previous behavior. Tree-SHA512: af2e9dd60d1ad030409ae2c3805ab139c7435327823d9f8bbeede815f376cb696a5929b08a6e8c8b5f7278ed49cfb231789f9041bd57f1f03ec96501b669da5b
This commit is contained in:
@@ -314,8 +314,9 @@ static bool InitRPCAuthentication()
|
||||
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.\n");
|
||||
strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
|
||||
}
|
||||
if (gArgs.GetArg("-rpcauth", "") != "") {
|
||||
LogPrintf("Using rpcauth authentication.\n");
|
||||
|
||||
if (!gArgs.GetArgs("-rpcauth").empty()) {
|
||||
LogInfo("Using rpcauth authentication.\n");
|
||||
for (const std::string& rpcauth : gArgs.GetArgs("-rpcauth")) {
|
||||
std::vector<std::string> fields{SplitString(rpcauth, ':')};
|
||||
const std::vector<std::string> salt_hmac{SplitString(fields.back(), '$')};
|
||||
|
||||
Reference in New Issue
Block a user