mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-08-04 05:54:48 +02:00
Merge branch 'fix_keep_notmy_cookie' into HEAD
This commit is contained in:
commit
907996129b
@ -80,7 +80,7 @@ static fs::path GetAuthCookieFile(bool temp=false)
|
|||||||
return AbsPathForConfigVal(gArgs, arg);
|
return AbsPathForConfigVal(gArgs, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_generated_cookie = false;
|
static std::optional<std::string> g_generated_cookie;
|
||||||
|
|
||||||
bool GenerateAuthCookie(std::string *cookie_out)
|
bool GenerateAuthCookie(std::string *cookie_out)
|
||||||
{
|
{
|
||||||
@ -107,7 +107,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
|
|||||||
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
|
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
g_generated_cookie = true;
|
g_generated_cookie = cookie;
|
||||||
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
|
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
|
||||||
|
|
||||||
if (cookie_out)
|
if (cookie_out)
|
||||||
@ -134,8 +134,9 @@ bool GetAuthCookie(std::string *cookie_out)
|
|||||||
void DeleteAuthCookie()
|
void DeleteAuthCookie()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (g_generated_cookie) {
|
std::string existing_cookie;
|
||||||
// Delete the cookie file if it was generated by this process
|
if (GetAuthCookie(&existing_cookie) && g_generated_cookie == existing_cookie) {
|
||||||
|
// Delete the cookie file if it exists and was generated by this process
|
||||||
fs::remove(GetAuthCookieFile());
|
fs::remove(GetAuthCookieFile());
|
||||||
}
|
}
|
||||||
} catch (const fs::filesystem_error& e) {
|
} catch (const fs::filesystem_error& e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user