Skip to content

Commit f9f6c11

Browse files
author
MarcoFalke
committed
Merge #15771: qa: Prevent concurrency issues reading .cookie file
90bce24 qa: Prevent concurrency issues reading .cookie file (João Barbosa) Pull request description: Hopefully fixes #15733. ACKs for commit 90bce2: Tree-SHA512: 4db06a63bb57e8ae56a4eab9d352a9a8d66dd7425cf491ca5f9e1ec5e60e61cb5af9eedbd32a0a9f9bdd770d767adf499eed05dd03221686eb357f6417441b61
2 parents f3ecf30 + 90bce24 commit f9f6c11

File tree

1 file changed

+3
-1
lines changed
  • test/functional/test_framework

1 file changed

+3
-1
lines changed

test/functional/test_framework/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,14 @@ def get_auth_cookie(datadir):
323323
if line.startswith("rpcpassword="):
324324
assert password is None # Ensure that there is only one rpcpassword line
325325
password = line.split("=")[1].strip("\n")
326-
if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")) and os.access(os.path.join(datadir, "regtest", ".cookie"), os.R_OK):
326+
try:
327327
with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f:
328328
userpass = f.read()
329329
split_userpass = userpass.split(':')
330330
user = split_userpass[0]
331331
password = split_userpass[1]
332+
except OSError:
333+
pass
332334
if user is None or password is None:
333335
raise ValueError("No RPC credentials")
334336
return user, password

0 commit comments

Comments
 (0)