Compare commits

...

3 Commits

Author SHA1 Message Date
Eelco Dolstra
1de323e9df Merge branch 'master' (reformat) 2025-07-23 21:23:25 +02:00
Eelco Dolstra
4eb2df09d1 Merge branch 'master' (pre-reformat) 2025-07-23 21:23:16 +02:00
Eelco Dolstra
3dc1b99be5 AllowListSourceAccessor: Make thread-safe 2025-07-15 19:44:13 +02:00

View File

@@ -1,4 +1,5 @@
#include "nix/fetchers/filtering-source-accessor.hh"
#include "nix/util/sync.hh"
namespace nix {
@@ -56,8 +57,8 @@ void FilteringSourceAccessor::checkAccess(const CanonPath & path)
struct AllowListSourceAccessorImpl : AllowListSourceAccessor
{
std::set<CanonPath> allowedPrefixes;
std::unordered_set<CanonPath> allowedPaths;
SharedSync<std::set<CanonPath>> allowedPrefixes;
SharedSync<std::unordered_set<CanonPath>> allowedPaths;
AllowListSourceAccessorImpl(
ref<SourceAccessor> next,
@@ -72,12 +73,12 @@ struct AllowListSourceAccessorImpl : AllowListSourceAccessor
bool isAllowed(const CanonPath & path) override
{
return allowedPaths.contains(path) || path.isAllowed(allowedPrefixes);
return allowedPaths.readLock()->contains(path) || path.isAllowed(*allowedPrefixes.readLock());
}
void allowPrefix(CanonPath prefix) override
{
allowedPrefixes.insert(std::move(prefix));
allowedPrefixes.lock()->insert(std::move(prefix));
}
};