pub struct Bwrap {
host_workdir: PathBuf,
args: Vec<OsString>,
inputs_provider: InputsProvider,
}Expand description
Bubblewrap based sandbox executor.
It executes the sandbox command in separate uts, ipc, pid and user namespaces,
always runs as uid=1000(nixbld) and gid=100(nixbld) inside the namespace. Provides sane
defaults for various /etc files.
Network is optionally disabled with a separate network namespace based on the value of SandboxSpec::allow_network.
The root filesystem is tmpfs, has /dev and /proc.
The rest of the filesystem is based on the SandboxSpec::scratches, SandboxSpec::additional_files and SandboxSpec::inputs_provider.
§Scratches
A list of read-write directories available inside the sandbox, these directories are also left available on the host after the sandbox has finished.
§Additional files
A list of read-write files whose path currently must resolve into one of the Scratches.
§Build Inputs(SandboxSpec::inputs_provider)
A read-only directory that contains any files required by the sandboxed command, e.g
/nix/store.
Before the sandbox starts, the SandboxSpec::inputs_provider will have a chance to populate
this directory and clean up after the sandbox is stopped.
Note: If the build inputs directory overlaps with any of the scratches, an overlayfs mount will be created for that scratch so it remains writable, i.e. the sandboxed command can create new files/directories.
Fields§
§host_workdir: PathBuf§args: Vec<OsString>§inputs_provider: InputsProviderImplementations§
Source§impl Bwrap
impl Bwrap
Sourcepub async fn run(self) -> Result<SandboxOutcome>
pub async fn run(self) -> Result<SandboxOutcome>
Run the sandbox and return the result.
Sourcepub fn initialize(spec: SandboxSpec) -> Result<Bwrap>
pub fn initialize(spec: SandboxSpec) -> Result<Bwrap>
Constructor.
Auto Trait Implementations§
impl Freeze for Bwrap
impl !RefUnwindSafe for Bwrap
impl Send for Bwrap
impl !Sync for Bwrap
impl Unpin for Bwrap
impl !UnwindSafe for Bwrap
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request