Previously, an exception would be thrown, which could kill the node in some circumstances.
Includes test changes to cause failure.
Review with ?w=1
Previously, an exception would be thrown, which could kill the node in some circumstances.
Includes test changes to cause failure.
Review with ?w=1
49@@ -50,6 +50,11 @@ def wallet_file(name):
50 os.mkdir(wallet_dir('w7'))
51 os.symlink('w7', wallet_dir('w7_symlink'))
52
53+ os.symlink('..', wallet_dir('recursive_dir_symlink'))
54+
55+ os.mkdir(wallet_dir('self_walletdat_symlink'))
56+ os.symlink('wallet.dat', wallet_dir('self_walletdat_symlink/wallet.dat'))
Verified that this does cause the test to fail at line 79 without the changes in this PR.
Could also assert that the new logging is taking place with this at line 79 or just after:
0with self.nodes[0].assert_debug_log(expected_msgs=['Too many levels of symbolic links', 'Error scanning']):
1 self.nodes[0].listwalletdir()['wallets']
(or combined with the existing line 79 to share the same listwalletdir call)
0- assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), ['', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8'])
1+ with self.nodes[0].assert_debug_log(expected_msgs=['Too many levels of symbolic links', 'Error scanning']):
2+ list = self.nodes[0].listwalletdir()['wallets']
3+ assert_equal(sorted(map(lambda w: w['name'], list)), ['', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8'])
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
re-ACK 1e77a8d5a4faa0757e53e0284662b249eebc3ef7
In the new test, the new exception prints:
[httpworker.1] ListWalletDir: Error scanning /tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink: boost::filesystem::status: Too many levels of symbolic links: “/tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat”
[httpworker.1] ListWalletDir: Error scanning /tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat: boost::filesystem::status: Too many levels of symbolic links: “/tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat”`
I don’t see what new issues (aside from rebasing) would be created by merging them separately?
iirc this a fix for the boost link problem and ( evil wallet ) and makes #18095 obsolete.
̶B̶u̶t̶ ̶i̶f̶ ̶t̶h̶i̶s̶ ̶g̶e̶t̶ ̶m̶e̶r̶g̶e̶d̶ ̶f̶i̶r̶s̶t̶,̶ ̶t̶h̶e̶n̶ ̶r̶e̶a̶l̶ ̶s̶h̶o̶r̶t̶ ̶f̶i̶l̶e̶n̶a̶m̶e̶s̶ ̶w̶a̶l̶l̶e̶t̶s̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶l̶a̶t̶e̶r̶ ̶f̶o̶u̶n̶d̶ ̶b̶u̶g̶ ̶c̶o̶u̶l̶d̶ ̶b̶e̶ ̶c̶r̶e̶a̶t̶e̶d̶ ̶f̶r̶o̶m̶ ̶a̶ ̶b̶o̶g̶u̶s̶ ̶d̶i̶r̶n̶a̶m̶e̶ ̶o̶n̶ ̶d̶i̶s̶k̶ ̶f̶o̶r̶ ̶r̶e̶a̶l̶.̶
But if this get merged first, then real short filenames wallets from the later found bug could be created from a bogus dirname on disk for real. @luke-jr Rechecked complies from the sources: To open non exitsting files, is no longer the case with current master and knots so no merge sequence preferences here any longer. Was only a problem short after those errors where found and exits only if direct on top of last releases before/= 0.20
re-ACK 9f74b7b3beba182d3b3118bf331515ef6e5ffcf2, only rebased since my previous review, verified with git range-diff master 1e77a8d5a 9f74b7b3b
.
Revoked. See #19502 (comment)
I revoke my ACK as this change makes possible an infinity loop. To reproduce the bug, one could create a directory without access permissions, e.g.:
0$ ls -l /home/hebasto/bitcoin-data-dir/wallets
1total 1456
2drwx------ 3 hebasto hebasto 4096 Oct 3 11:16 20191109-main
3drwx------ 2 root root 4096 Oct 20 23:58 crash
4-rw-r--r-- 1 hebasto hebasto 0 Mar 5 2020 db.log
5drwx------ 3 hebasto hebasto 4096 Oct 20 23:56 w20201015.bdb
6drwx------ 3 hebasto hebasto 4096 Oct 20 23:56 w20201015.desc
7-rw-r----- 1 hebasto hebasto 1474560 Sep 12 16:08 wallet.dat
I suggest to combine into this PR the approach from #18095: https://github.com/bitcoin/bitcoin/blob/6904a309194c7ddf5a071d43e6c2bf892e8fe396/src/wallet/walletutil.cpp#L42-L53 with credits to @uhliksk
Tested 49cc6919c4f9ef5a33ad5948a1b43496b454fab0, still able to reproduce an infinite loop:
0cd <path-to-wallet-dir>
1sudo mkdir crash
2sudo chown 0700 crash
then start a node, and initiate a ListWalletDir
call in any way.
Approach ACK 44c0bc31f4fadc932877d9764402644c84f3be4c, tested on Linux Mint 20 (x86_64).
Instead of an infinite loop having a nice log message:
02020-10-29T20:41:26Z [main] ListWalletDir: Error scanning /home/hebasto/.bitcoin/testnet3/wallets/crash: boost::filesystem::status: Permission denied: "/home/hebasto/.bitcoin/testnet3/wallets/crash/wallet.dat"
Keeping reviewing the last commit.
114@@ -109,7 +115,16 @@ def wallet_file(name):
115 self.nodes[0].createwallet(wallet_name, descriptors=False)
116 for wallet_name in wallet_names[-2:]:
117 self.nodes[0].loadwallet(wallet_name)
118- assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8'])
119+
120+ os.mkdir(wallet_dir('no_access'))
121+ os.chmod(wallet_dir('no_access'), 0)
44c0bc31f4fadc932877d9764402644c84f3be4c
If this line is commented out, the test still passing.
no_access
directory actually has access, the test should fail, right?
No, it’s just there to make sure it doesn’t break things. We’re testing bitcoind, not the OS…
(And in fact, chmod won’t work to deny read access on Windows)
88+ paths.emplace_back(path);
89+ }
90 }
91+ } catch (const std::exception& e) {
92+ LogPrintf("%s: Error scanning %s: %s\n", __func__, it->path().string(), e.what());
93+ it.no_push();
Tested ACK 24d2d3341d07509ad3f37bb6f130446ad20ac807, test change fails on master.
nit, could squash.