1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 06:21:14 +02:00

findRoots(): Add 'censor' parameter

This is less brittle than filtering paths after the fact in
nix-daemon.
This commit is contained in:
Eelco Dolstra 2019-03-14 13:50:07 +01:00
parent a3f37d87ea
commit 53522cb6ac
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
7 changed files with 40 additions and 53 deletions

View file

@ -475,40 +475,19 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
case wopFindRoots: {
logger->startWork();
Roots roots = store->findRoots();
Roots roots = store->findRoots(true);
logger->stopWork();
// Pre-compute roots length using same algo as below.
size_t total_length = 0;
bool hasMemoryLink;
for (auto & root : roots) {
hasMemoryLink = false;
for (auto & link : root.second) {
if (link.rfind("{memory:", 0) == 0) {
if (hasMemoryLink) continue;
++total_length;
hasMemoryLink = true;
} else {
++total_length;
}
}
}
size_t size = 0;
for (auto & i : roots)
size += i.second.size();
to << size;
for (auto & [target, links] : roots)
for (auto & link : links)
to << link << target;
to << total_length;
int n = 0;
for (auto & [target, links] : roots) {
bool hasMemoryLink = false;
for (auto & link : links) {
// Obfuscate 'memory' roots as they expose information about other users,
if (link.rfind("{memory:", 0) == 0) {
if (hasMemoryLink) continue;
to << fmt("{memory:%d}", n++) << target;
hasMemoryLink = true;
} else {
to << link << target;
}
}
}
break;
}