File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ static fs::path GetAuthCookieFile(bool temp=false)
80
80
return AbsPathForConfigVal (gArgs , arg);
81
81
}
82
82
83
+ static bool g_generated_cookie = false ;
84
+
83
85
bool GenerateAuthCookie (std::string *cookie_out)
84
86
{
85
87
const size_t COOKIE_SIZE = 32 ;
@@ -105,6 +107,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
105
107
LogPrintf (" Unable to rename cookie authentication file %s to %s\n " , fs::PathToString (filepath_tmp), fs::PathToString (filepath));
106
108
return false ;
107
109
}
110
+ g_generated_cookie = true ;
108
111
LogPrintf (" Generated RPC authentication cookie %s\n " , fs::PathToString (filepath));
109
112
110
113
if (cookie_out)
@@ -131,7 +134,10 @@ bool GetAuthCookie(std::string *cookie_out)
131
134
void DeleteAuthCookie ()
132
135
{
133
136
try {
134
- fs::remove (GetAuthCookieFile ());
137
+ if (g_generated_cookie) {
138
+ // Delete the cookie file if it was generated by this process
139
+ fs::remove (GetAuthCookieFile ());
140
+ }
135
141
} catch (const fs::filesystem_error& e) {
136
142
LogPrintf (" %s: Unable to remove random auth cookie file: %s\n " , __func__, fsbridge::get_filesystem_error_message (e));
137
143
}
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ def run_test(self):
30
30
expected_msg = f"Error: Cannot obtain a lock on data directory { datadir } . { self .config ['environment' ]['PACKAGE_NAME' ]} is probably already running."
31
31
self .nodes [1 ].assert_start_raises_init_error (extra_args = [f'-datadir={ self .nodes [0 ].datadir_path } ' , '-noserver' ], expected_msg = expected_msg )
32
32
33
+ cookie_file = datadir / ".cookie"
34
+ assert cookie_file .exists () # should not be deleted during the second bitcoind instance shutdown
35
+
33
36
if self .is_wallet_compiled ():
34
37
def check_wallet_filelock (descriptors ):
35
38
wallet_name = '' .join ([random .choice (string .ascii_lowercase ) for _ in range (6 )])
You can’t perform that action at this time.
0 commit comments