Skip to main content

Translator

Struct Translator 

Source
pub struct Translator { /* private fields */ }
Expand description

The translator: a backend plus a shared fid table.

Cloning is cheap (Arc internals); one translator serves many connections.

Implementations§

Source§

impl Translator

Source

pub fn new(backend: Arc<dyn Backend>, decider: Arc<dyn AccessDecider>) -> Self

Build a translator over the given backend and mandatory audited PEP.

Source

pub fn with_reference_monitor(self, monitor: Arc<ReferenceMonitor>) -> Self

Install the S2 reference monitor: every dispatched op on every fid is then mediated (attach-time token verification, trusted label resolution, token gate, independent IFC dominance, then the local AVC/PDP), failing closed at each step. Without this call the translator enforces nothing — the dormant pre-activation default.

Source

pub fn from_mount( mount: Arc<dyn Mount>, subject: Subject, decider: Arc<dyn AccessDecider>, ) -> Self

Build a translator that exports a single Subject-scoped VFS [Mount] as its 9P root.

This is the entry point for #506: mount is the tenant’s export root (already the single MAC policy-enforcement point) and subject is the verified caller identity threaded onto every backend op. It wraps the mount in a MountBackend — the same Backend seam the capnp-RPC ModelBackend uses on the TCP path — so no new attachment mechanism is introduced; only the export root differs.

Source

pub fn from_mount_authorized( mount: Arc<dyn Mount>, authorizer: Arc<dyn AttachAuthorizer>, decider: Arc<dyn AccessDecider>, ) -> Self

Build a translator that exports mount, resolving the session [Subject] from the mount ticket the client presents in Tattach.uname via authorizer (H1b /9p WebTransport plane, #765).

Unlike from_mount — where the caller identity is fixed at construction (a UDS/vsock listener serves exactly one tenant) — the WebTransport plane serves a cert-pinned mesh session over which a tenant proves identity at attach. The Subject is bound once, at the first successful Tattach, and threaded onto every op by MountBackend thereafter; a denied ticket fails the attach with an Rlerror (see MountBackend::with_authorizer). Every other layer — the serve loop, fid table, errno mapping — is identical to from_mount.

Source

pub fn with_activation_control(self) -> Self

Use the process-global coverage-gated widen/narrow control. Production constructors call this after installing the mandatory monitor.

Source

pub async fn serve(self, listener: TcpListener) -> Result<()>

Run a TCP accept loop until the listener errors or is closed.

Each connection runs on its own task. Errors on one connection do not affect siblings.

Source

pub async fn serve_uds(self, listener: UnixListener) -> Result<()>

Run the accept loop over a Unix domain socket.

Identical per-connection handling to Translator::serve; only the transport differs. This is how a native Wanix workload attaches to a Subject-scoped export over a UDS via its p9kit.ClientFS 9P client.

Source

pub async fn serve_vsock(self, listener: UnixListener) -> Result<()>

Run the accept loop over a Cloud-Hypervisor hybrid-vsock host socket.

The vsock sibling of serve_uds, and the entry point a kata guest dials to operate the host VFS over native 9P (#730). CH’s ch path has no virtio-9p, so the guest reaches the host by opening a vsock connection; CH surfaces that as a host Unix socket whose accepted connections each begin with a connect <port>\n text preamble (the firecracker/CH multiplexer handshake — the reverse of kata_agent::hybrid_vsock_connect). This entry strips and acknowledges that preamble per connection, then runs the identical serve_connection core as serve / serve_uds; the Subject-per-op enforcement is unchanged — only the transport differs.

Source

pub async fn serve_vsock_raw(self, listener: UnixListener) -> Result<()>

Run the accept loop over a raw (no-handshake) hybrid-vsock host socket: a per-port host UDS the guest dials.

The raw sibling of serve_vsock. Where [serve_vsock] plays the CH host-multiplexer role for connections hyprstream initiates — and therefore strips a connect <port>\n text preamble off each accepted stream — this entry point serves a per-port host listener (<vsock-base>_<port>, e.g. VFS_9P_VSOCK_PORT=564) that the guest connects to. Per the Firecracker/CH hybrid-vsock spec, guest-initiated connections to a per-port host UDS arrive raw: there is no connect <port>\n preamble (the port is already encoded in the socket path, not in an in-band handshake). Stripping a preamble here would eat the guest’s first 9P Tversion bytes and break the handshake (#741).

So this hands each accepted [UnixStream] straight to the shared serve_connection core with no preamble strip. The Subject-per-op enforcement and wire-faithful 9P2000.L framing are byte-identical to every other transport; only the accept surface differs (raw, via [RawVsockListener]).

Source

pub async fn serve_connection<S>(self: &Arc<Self>, stream: S) -> Result<()>
where S: AsyncRead + AsyncWrite + Send + 'static,

Serve a single connection to completion (until EOF, parse error, or the peer resets).

Generic over the byte stream so the same core serves TCP, UDS, and any future AsyncRead + AsyncWrite transport.

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,