1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 05:56:03 +01:00

Censor the gc roots that aren’t under stateDir

This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent 8f622ff71b
commit e1df6c220a

View file

@ -340,11 +340,13 @@ Roots LocalStore::findRoots(bool censor)
if (parsedLine.size() != 2)
throw Error("Invalid result from the gc helper");
auto rawDestPath = parsedLine[0];
auto retainer = parsedLine[1];
if (!isInStore(rawDestPath)) continue;
try {
auto destPath = toStorePath(rawDestPath).first;
if (!isValidPath(destPath)) continue;
roots[destPath].insert(parsedLine[1]);
roots[destPath].insert(
(!censor || isInDir(retainer, stateDir)) ? retainer : censored);
} catch (Error &) {
}
}