1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00

Fix "access to path is forbidden"

This commit is contained in:
Eelco Dolstra 2024-04-16 18:40:00 +02:00
parent 978b3648df
commit b3a6b794b0
3 changed files with 9 additions and 1 deletions

View file

@ -15,6 +15,12 @@ bool FilteringInputAccessor::pathExists(const CanonPath & path)
return isAllowed(path) && next->pathExists(prefix / path);
}
SourceAccessor::Stat FilteringInputAccessor::lstat(const CanonPath & path)
{
checkAccess(path);
return next->lstat(prefix / path);
}
std::optional<InputAccessor::Stat> FilteringInputAccessor::maybeLstat(const CanonPath & path)
{
return isAllowed(path) ? next->maybeLstat(prefix / path) : std::nullopt;

View file

@ -33,6 +33,8 @@ struct FilteringInputAccessor : InputAccessor
bool pathExists(const CanonPath & path) override;
Stat lstat(const CanonPath & path) override;
std::optional<Stat> maybeLstat(const CanonPath & path) override;
DirEntries readDirectory(const CanonPath & path) override;

View file

@ -111,7 +111,7 @@ struct SourceAccessor
std::optional<uint64_t> narOffset;
};
Stat lstat(const CanonPath & path);
virtual Stat lstat(const CanonPath & path);
virtual std::optional<Stat> maybeLstat(const CanonPath & path) = 0;