mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
args: Support -norpccookiefile for bitcoind and bitcoin-cli
Replaces belt & suspenders check for initialization in RPCAuthorized() with not allowing empty passwords further down.
This commit is contained in:
parent
e82ad88452
commit
39cbd4f37c
2 changed files with 18 additions and 6 deletions
|
|
@ -86,6 +86,9 @@ static const char* const COOKIEAUTH_FILE = ".cookie";
|
|||
static fs::path GetAuthCookieFile(bool temp=false)
|
||||
{
|
||||
fs::path arg = gArgs.GetPathArg("-rpccookiefile", COOKIEAUTH_FILE);
|
||||
if (arg.empty()) {
|
||||
return {}; // -norpccookiefile was specified
|
||||
}
|
||||
if (temp) {
|
||||
arg += ".tmp";
|
||||
}
|
||||
|
|
@ -106,6 +109,9 @@ bool GenerateAuthCookie(std::string* cookie_out, std::optional<fs::perms> cookie
|
|||
*/
|
||||
std::ofstream file;
|
||||
fs::path filepath_tmp = GetAuthCookieFile(true);
|
||||
if (filepath_tmp.empty()) {
|
||||
return true; // -norpccookiefile
|
||||
}
|
||||
file.open(filepath_tmp);
|
||||
if (!file.is_open()) {
|
||||
LogWarning("Unable to open cookie authentication file %s for writing", fs::PathToString(filepath_tmp));
|
||||
|
|
@ -142,6 +148,9 @@ bool GetAuthCookie(std::string *cookie_out)
|
|||
std::ifstream file;
|
||||
std::string cookie;
|
||||
fs::path filepath = GetAuthCookieFile();
|
||||
if (filepath.empty()) {
|
||||
return true; // -norpccookiefile
|
||||
}
|
||||
file.open(filepath);
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue