Skip to content

Commit

Permalink
Merge branch 'auxpow-26.x' into 26.x
Browse files Browse the repository at this point in the history
  • Loading branch information
domob1812 committed Mar 5, 2024
2 parents 17c15ca + 5d39cf9 commit 2a85890
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rpc/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ static fs::path GetAuthCookieFile(bool temp=false)
return AbsPathForConfigVal(gArgs, arg);
}

static bool g_generated_cookie = false;

bool GenerateAuthCookie(std::string *cookie_out)
{
const size_t COOKIE_SIZE = 32;
Expand All @@ -105,6 +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));
return false;
}
g_generated_cookie = true;
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));

if (cookie_out)
Expand All @@ -131,7 +134,10 @@ bool GetAuthCookie(std::string *cookie_out)
void DeleteAuthCookie()
{
try {
fs::remove(GetAuthCookieFile());
if (g_generated_cookie) {
// Delete the cookie file if it was generated by this process
fs::remove(GetAuthCookieFile());
}
} catch (const fs::filesystem_error& e) {
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
}
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def run_test(self):
expected_msg = f"Error: Cannot obtain a lock on data directory {datadir}. {self.config['environment']['PACKAGE_NAME']} is probably already running."
self.nodes[1].assert_start_raises_init_error(extra_args=[f'-datadir={self.nodes[0].datadir_path}', '-noserver'], expected_msg=expected_msg)

cookie_file = datadir / ".cookie"
assert cookie_file.exists() # should not be deleted during the second bitcoind instance shutdown

if self.is_wallet_compiled():
def check_wallet_filelock(descriptors):
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])
Expand Down

0 comments on commit 2a85890

Please sign in to comment.