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
impl Translator
Sourcepub fn new(backend: Arc<dyn Backend>, decider: Arc<dyn AccessDecider>) -> Self
pub fn new(backend: Arc<dyn Backend>, decider: Arc<dyn AccessDecider>) -> Self
Build a translator over the given backend and mandatory audited PEP.
Sourcepub fn with_reference_monitor(self, monitor: Arc<ReferenceMonitor>) -> Self
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.
Sourcepub fn from_mount(
mount: Arc<dyn Mount>,
subject: Subject,
decider: Arc<dyn AccessDecider>,
) -> Self
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.
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.
Sourcepub fn with_activation_control(self) -> Self
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.
Sourcepub async fn serve(self, listener: TcpListener) -> Result<()>
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.
Sourcepub async fn serve_uds(self, listener: UnixListener) -> Result<()>
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.
Sourcepub async fn serve_vsock(self, listener: UnixListener) -> Result<()>
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.
Sourcepub async fn serve_vsock_raw(self, listener: UnixListener) -> Result<()>
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]).
Sourcepub async fn serve_connection<S>(self: &Arc<Self>, stream: S) -> Result<()>where
S: AsyncRead + AsyncWrite + Send + 'static,
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§
impl !Freeze for Translator
impl !RefUnwindSafe for Translator
impl Send for Translator
impl Sync for Translator
impl Unpin for Translator
impl UnsafeUnpin for Translator
impl !UnwindSafe for Translator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more