mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Merge pull request #14534 from NixOS/backport-14531-to-2.32-maintenance
[Backport 2.32-maintenance] Restore isAllowed check in ChrootLinuxDerivationBuilder
This commit is contained in:
commit
d7fc293353
3 changed files with 21 additions and 7 deletions
|
|
@ -52,7 +52,21 @@ struct RestrictionContext
|
||||||
* Add 'path' to the set of paths that may be referenced by the
|
* Add 'path' to the set of paths that may be referenced by the
|
||||||
* outputs, and make it appear in the sandbox.
|
* 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void addDependency(const StorePath & path) override;
|
void addDependencyImpl(const StorePath & path) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a file owned by the builder.
|
* Make a file owned by the builder.
|
||||||
|
|
@ -1181,11 +1181,8 @@ void DerivationBuilderImpl::stopDaemon()
|
||||||
daemonSocket.close();
|
daemonSocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DerivationBuilderImpl::addDependency(const StorePath & path)
|
void DerivationBuilderImpl::addDependencyImpl(const StorePath & path)
|
||||||
{
|
{
|
||||||
if (isAllowed(path))
|
|
||||||
return;
|
|
||||||
|
|
||||||
addedPaths.insert(path);
|
addedPaths.insert(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -703,8 +703,11 @@ struct ChrootLinuxDerivationBuilder : ChrootDerivationBuilder, LinuxDerivationBu
|
||||||
DerivationBuilderImpl::killSandbox(getStats);
|
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);
|
auto [source, target] = ChrootDerivationBuilder::addDependencyPrep(path);
|
||||||
|
|
||||||
/* Bind-mount the path into the sandbox. This requires
|
/* Bind-mount the path into the sandbox. This requires
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue