Skip to content

Commit 24d2d33

Browse files
committed
QA: wallet_multiwallet: Check that recursive symlink directory and wallet.dat loops are ignored
1 parent 69f59af commit 24d2d33

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/functional/wallet_multiwallet.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from threading import Thread
1111
import os
1212
import shutil
13+
import stat
1314
import time
1415

1516
from test_framework.authproxy import JSONRPCException
@@ -78,6 +79,11 @@ def wallet_file(name):
7879
os.mkdir(wallet_dir('w7'))
7980
os.symlink('w7', wallet_dir('w7_symlink'))
8081

82+
os.symlink('..', wallet_dir('recursive_dir_symlink'))
83+
84+
os.mkdir(wallet_dir('self_walletdat_symlink'))
85+
os.symlink('wallet.dat', wallet_dir('self_walletdat_symlink/wallet.dat'))
86+
8187
# rename wallet.dat to make sure plain wallet file paths (as opposed to
8288
# directory paths) can be loaded
8389
# create another dummy wallet for use in testing backups later
@@ -117,7 +123,16 @@ def wallet_file(name):
117123
self.nodes[0].createwallet(wallet_name)
118124
for wallet_name in to_load:
119125
self.nodes[0].loadwallet(wallet_name)
120-
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), sorted(in_wallet_dir))
126+
127+
os.mkdir(wallet_dir('no_access'))
128+
os.chmod(wallet_dir('no_access'), 0)
129+
try:
130+
with self.nodes[0].assert_debug_log(expected_msgs=['Too many levels of symbolic links', 'Error scanning']):
131+
walletlist = self.nodes[0].listwalletdir()['wallets']
132+
finally:
133+
# Need to ensure access is restored for cleanup
134+
os.chmod(wallet_dir('no_access'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
135+
assert_equal(sorted(map(lambda w: w['name'], walletlist)), sorted(in_wallet_dir))
121136

122137
assert_equal(set(node.listwallets()), set(wallet_names))
123138

0 commit comments

Comments
 (0)