v30.3-roots.1 · Commit 4: [PATCH 04/68] fix(wallet): preserve Roots database hardening on Core 30.3
src/wallet/db.cpp
Before: src/wallet/db.cpp · After: src/wallet/db.cpp
File metadata
index 781b6fa461dcccdd7733d5409e7a0be80feade02..237aa6acc1987d03fb4292890742a33dda97b7a1 100644
Download original patch · Release notes
Diff rows 1–58 of 58. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/wallet/db.cpp
CHANGED
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
#include <common/args.h>
|
|
8
8
|
#include <logging.h>
|
|
9
9
|
#include <util/fs.h>
|
|
10
|
+
#include <util/fs_helpers.h>
|
|
10
11
|
#include <wallet/db.h>
|
|
11
12
|
|
|
12
13
|
#include <algorithm>
|
|
13
14
|
#include <exception>
|
|
14
15
|
#include <fstream>
|
|
16
|
+
#include <set>
|
|
15
17
|
#include <string>
|
|
16
18
|
#include <system_error>
|
|
17
19
|
#include <vector>
|
|
@@ -22,14 +24,45 @@ bool operator<(std::span<const std::byte> a, BytePrefix b) { return std::ranges:
|
|
|
22
24
|
|
|
23
25
|
std::vector<std::pair<fs::path, std::string>> ListDatabases(const fs::path& wallet_dir)
|
|
24
26
|
{
|
|
27
|
+
const fs::path& data_dir = gArgs.GetDataDirNet();
|
|
28
|
+
const fs::path& blocks_dir = gArgs.GetBlocksDirPath();
|
|
29
|
+
|
|
30
|
+
// Here we place the top level dirs we want to skip in case walletdir is datadir or blocksdir
|
|
31
|
+
// Those directories are referenced in doc/files.md
|
|
32
|
+
const std::set<fs::path> ignore_paths = {
|
|
33
|
+
blocks_dir,
|
|
34
|
+
data_dir / "blktree",
|
|
35
|
+
data_dir / "blocks",
|
|
36
|
+
data_dir / "chainstate",
|
|
37
|
+
data_dir / "coins",
|
|
38
|
+
data_dir / "database",
|
|
39
|
+
data_dir / "indexes",
|
|
40
|
+
data_dir / "regtest",
|
|
41
|
+
data_dir / "signet",
|
|
42
|
+
data_dir / "testnet3",
|
|
43
|
+
data_dir / "testnet4"
|
|
44
|
+
};
|
|
45
|
+
|
|
25
46
|
std::vector<std::pair<fs::path, std::string>> paths;
|
|
26
47
|
std::error_code ec;
|
|
27
48
|
|
|
28
49
|
for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
|
|
29
50
|
assert(!ec); // Loop should exit on error.
|
|
51
|
+
|
|
52
|
+
// We don't want to iterate through those special node dirs
|
|
53
|
+
if (ignore_paths.count(it->path())) {
|
|
54
|
+
it.disable_recursion_pending();
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
30
58
|
try {
|
|
31
59
|
const fs::path path{it->path().lexically_relative(wallet_dir)};
|
|
32
60
|
|
|
61
|
+
if (IsSymlink(it->path())) {
|
|
62
|
+
LogWarning("Not recursively searching symlink/reparse point at '%s'", fs::PathToString(it->path()));
|
|
63
|
+
it.disable_recursion_pending();
|
|
64
|
+
}
|
|
65
|
+
|
|
33
66
|
if (it->status().type() == fs::file_type::directory) {
|
|
34
67
|
if (IsBDBFile(BDBDataFile(it->path()))) {
|
|
35
68
|
// Found a directory which contains wallet.dat btree file, add it as a wallet with BERKELEY format.
|