1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 14:32:42 +01:00

Also check the NixOS specific files

This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent 61c35a810b
commit 3839eb15d6

View file

@ -197,6 +197,9 @@ TraceResult followPathsToStore(GlobalOpts opts, set<fs::path> roots)
*/ */
void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res) void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res)
{ {
if (!fs::exists(fileToScan))
return;
std::ostringstream contentStream; std::ostringstream contentStream;
{ {
std::ifstream fs; std::ifstream fs;
@ -218,6 +221,9 @@ void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots
*/ */
void scanMapsFile(const GlobalOpts & opts, const fs::path & mapsFile, Roots & res) void scanMapsFile(const GlobalOpts & opts, const fs::path & mapsFile, Roots & res)
{ {
if (!fs::exists(mapsFile))
return;
static auto mapRegex = std::regex(R"(^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(/\S+)\s*$)"); static auto mapRegex = std::regex(R"(^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(/\S+)\s*$)");
std::stringstream mappedFile; std::stringstream mappedFile;
{ {
@ -275,6 +281,13 @@ Roots getRuntimeRoots(GlobalOpts opts)
scanFileContent(opts, procEntry.path()/"environ", res); scanFileContent(opts, procEntry.path()/"environ", res);
scanMapsFile(opts, procEntry.path()/"maps", res); scanMapsFile(opts, procEntry.path()/"maps", res);
} }
// Mostly useful for NixOS, but doesnt hurt to check on other systems
// anyways
scanFileContent(opts, "/proc/sys/kernel/modprobe", res);
scanFileContent(opts, "/proc/sys/kernel/fbsplash", res);
scanFileContent(opts, "/proc/sys/kernel/poweroff_cmd", res);
return res; return res;
} }