Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/libstore/include/nix/store/restricted-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ struct RestrictionContext
* Add 'path' to the set of paths that may be referenced by the
* outputs, and make it appear in the sandbox.
*/
virtual void addDependency(const StorePath & path) = 0;
void addDependency(const StorePath & path)
{
if (isAllowed(path))
return;
addDependencyImpl(path);
}

protected:

/**
* This is the underlying implementation to be defined. The caller
* will ensure that this is only called on newly added dependencies,
* and that idempotent calls are a no-op.
*/
virtual void addDependencyImpl(const StorePath & path) = 0;
};

/**
Expand Down
7 changes: 2 additions & 5 deletions src/libstore/unix/build/derivation-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class DerivationBuilderImpl : public DerivationBuilder, public DerivationBuilder

protected:

void addDependency(const StorePath & path) override;
void addDependencyImpl(const StorePath & path) override;

/**
* Make a file owned by the builder.
Expand Down Expand Up @@ -1203,11 +1203,8 @@ void DerivationBuilderImpl::stopDaemon()
daemonSocket.close();
}

void DerivationBuilderImpl::addDependency(const StorePath & path)
void DerivationBuilderImpl::addDependencyImpl(const StorePath & path)
{
if (isAllowed(path))
return;

addedPaths.insert(path);
}

Expand Down
5 changes: 4 additions & 1 deletion src/libstore/unix/build/linux-derivation-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,11 @@ struct ChrootLinuxDerivationBuilder : ChrootDerivationBuilder, LinuxDerivationBu
DerivationBuilderImpl::killSandbox(getStats);
}

void addDependency(const StorePath & path) override
void addDependencyImpl(const StorePath & path) override
{
if (isAllowed(path))
return;

auto [source, target] = ChrootDerivationBuilder::addDependencyPrep(path);

/* Bind-mount the path into the sandbox. This requires
Expand Down
Loading