Skip to main content

Launch

Struct Launch 

Source
#[non_exhaustive]
pub struct Launch { pub environment: Option<Vec<EnvironmentVariable>>, pub home: Option<Home>, pub identity: Option<Identity>, pub network: NetworkRights, }
Expand description

Optional parameters of a launch beyond the program’s arguments and streams.

A handler applies the home capability only if its format supports one. It must apply environment in every case and fail the launch if it cannot: an explicit environment is a confinement request, so ignoring it would hand the program the caller’s whole environment (fail closed).

An identity is applied to mounted native executables only: the launch of any registered file format (WebAssembly, native images) with an identity is refused, so a format handler never has to apply one (fail closed).

network is denied by default: a program gets network authority only from an explicit Launch::with_network, and only formats with a socket interface apply it (native executables, through XilaStartup.network). WebAssembly applications get no sockets, so a grant has no effect on them.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§environment: Option<Vec<EnvironmentVariable>>

The program’s whole environment, replacing the copy its task makes of the parent’s. A later variable overrides an earlier one of the same name.

§home: Option<Home>

Home directory capability for programs that take one (native executables).

§identity: Option<Identity>

The user and group of the new task, replacing the ones it inherits from its parent. Deciding who may run a program as another user is the caller’s job (see Launch::with_identity).

§network: NetworkRights

The network rights of the program. None by default (see Launch::with_network).

Implementations§

Source§

impl Launch

Source

pub fn with_environment(self, environment: Vec<EnvironmentVariable>) -> Self

Give the program this whole environment instead of a copy of its parent’s.

Source

pub fn with_home(self, home: Home) -> Self

Give the program this home directory capability.

Source

pub fn with_identity(self, user: UserIdentifier, group: GroupIdentifier) -> Self

Run the program as user and group instead of the caller’s identity.

The identity is set on the new task before the program starts, and only on that task (and the tasks it starts): the caller’s own identity never changes. The new task and all its descendants are marked as running with a granted identity, which they cannot clear (task::Manager::is_identity_granted), so runtimes for untrusted code can refuse to run under it. The execute permission is checked for user. The caller must have authorized the change itself, for example by authenticating an administrator, because this function grants it unconditionally.

Source

pub fn with_network(self, rights: NetworkRights) -> Self

Grant the program these network rights. Without this call it has no network.

A native process that spawns a child can pass it a subset of these rights and never more. Deciding which programs may use the network is the caller’s job: this function grants the rights unconditionally.

Trait Implementations§

Source§

impl Default for Launch

Source§

fn default() -> Launch

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.