WEFT_OS/crates/weft-app-shell/src/main.rs
Marco Allegretti 2148ffc8ae
fix(appd): resolve each launch to one package and fail closed on images
The runtime, the app shell and grant derivation each searched the
package stores and parsed wapp.toml on their own, so they could use
different roots; the runtime ignored [runtime].module, the image loader
looked for companion files the builder never wrote, and a failed image
mount fell back to the mutable directory install.

weft-appd now resolves a launch once: a verified image wins over a
directory in the same store, and when any image file exists the image
must mount or the launch is refused. The manifest must declare the
requested ID, and both entries must be plain relative paths to regular
files without links. The runtime receives --module and the app shell
--ui; neither looks for the package. Grants come from the same
manifest, and the mount belongs to the session.

The manifest parser and the image file names move to weft-ipc-types,
shared with weft-pack, whose check now applies the same entry rules.
Mapper devices are named after their per-launch mountpoint, so
concurrent sessions no longer collide.
2026-10-09 10:03:40 +00:00

70 lines
1.9 KiB
Rust

#[cfg(feature = "servo-embed")]
mod protocols;
#[cfg(feature = "servo-embed")]
mod shell_client;
#[cfg(feature = "servo-embed")]
mod embedder;
#[cfg(feature = "servo-embed")]
mod keyutils;
use anyhow::Context;
fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.init();
const USAGE: &str = "usage: weft-app-shell <app_id> <session_id> --ui <path>";
let mut args = std::env::args().skip(1);
let app_id = args.next().context(USAGE)?;
let session_id: u64 = args
.next()
.context(USAGE)?
.parse()
.context("session_id must be a number")?;
let ui = match (args.next().as_deref(), args.next(), args.next()) {
(Some("--ui"), Some(path), None) => std::path::PathBuf::from(path),
_ => anyhow::bail!(USAGE),
};
let ws_port = appd_ws_port();
embed_app(&app_id, session_id, ws_port, &ui)
}
fn appd_ws_port() -> u16 {
if let Ok(runtime_dir) = std::env::var("XDG_RUNTIME_DIR") {
let port_file = std::path::PathBuf::from(runtime_dir).join("weft/appd.wsport");
if let Ok(s) = std::fs::read_to_string(port_file)
&& let Ok(n) = s.trim().parse()
{
return n;
}
}
if let Ok(s) = std::env::var("WEFT_APPD_WS_PORT")
&& let Ok(n) = s.parse()
{
return n;
}
7410
}
fn embed_app(
app_id: &str,
session_id: u64,
ws_port: u16,
ui: &std::path::Path,
) -> anyhow::Result<()> {
#[cfg(feature = "servo-embed")]
return embedder::run(app_id, session_id, ws_port, ui);
#[cfg(not(feature = "servo-embed"))]
{
let _ = (app_id, session_id, ws_port, ui);
anyhow::bail!("weft-app-shell was built without the servo-embed feature and cannot render")
}
}