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)
8080 return AbsPathForConfigVal (gArgs , arg);
8181}
8282
83+ static bool g_generated_cookie = false ;
84+
8385bool GenerateAuthCookie (std::string *cookie_out)
8486{
8587 const size_t COOKIE_SIZE = 32 ;
@@ -105,6 +107,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
105107 LogPrintf (" Unable to rename cookie authentication file %s to %s\n " , fs::PathToString (filepath_tmp), fs::PathToString (filepath));
106108 return false ;
107109 }
110+ g_generated_cookie = true ;
108111 LogPrintf (" Generated RPC authentication cookie %s\n " , fs::PathToString (filepath));
109112
110113 if (cookie_out)
@@ -131,7 +134,10 @@ bool GetAuthCookie(std::string *cookie_out)
131134void DeleteAuthCookie ()
132135{
133136 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+ }
135141 } catch (const fs::filesystem_error& e) {
136142 LogPrintf (" %s: Unable to remove random auth cookie file: %s\n " , __func__, fsbridge::get_filesystem_error_message (e));
137143 }
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ def run_test(self):
3030 expected_msg = f"Error: Cannot obtain a lock on data directory { datadir } . { self .config ['environment' ]['PACKAGE_NAME' ]} is probably already running."
3131 self .nodes [1 ].assert_start_raises_init_error (extra_args = [f'-datadir={ self .nodes [0 ].datadir_path } ' , '-noserver' ], expected_msg = expected_msg )
3232
33+ cookie_file = datadir / ".cookie"
34+ assert cookie_file .exists () # should not be deleted during the second bitcoind instance shutdown
35+
3336 if self .is_wallet_compiled ():
3437 def check_wallet_filelock (descriptors ):
3538 wallet_name = '' .join ([random .choice (string .ascii_lowercase ) for _ in range (6 )])
You can’t perform that action at this time.
0 commit comments