windows: the component manager, verified programs, a Wine test
components.json pins sing-box, XRay, Flowseal's zapret, bol-van's winws2 bundle with nfqws2-keenetic's strategies, and tg-ws-proxy (built with the release): release assets by archive hash, commit snapshots by the hash of every file taken. The service installs them (admin only), staged and swapped in, refusing archive paths that leave the directory, and checks each program against the hashes recorded at install before running it. stage-components does the same for building a release. The state root is created with its protected descriptor in one call, or, existing, checked through a handle that does not follow links. tools/wine-e2e.sh runs the Windows build under Wine: the service, the named pipe, impersonation, the component check, rendering and the supervisor all work; Wine lacks an iphlpapi call sing-box needs, so proxying itself needs real Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b878dd93db
commit
68b496cafa
10 files changed
+709
-81
No files matched your search
@@ -428,7 +428,58 @@ pub async fn handle(req: Request, peer: &Peer, shared: &Shared) -> Response {
|
||||
Response::ok(json!(out))
|
||||
}
|
||||
|
||||
Request::Components | Request::ComponentsInstall { .. } => Response::err("the component manager is not there yet"),
|
||||
Request::Components => {
|
||||
let s = shared.lock().await;
|
||||
let bin = s.paths().bin();
|
||||
let list: Vec<Value> = ps_core::components::manifest()
|
||||
.components
|
||||
.iter()
|
||||
.map(|(name, c)| {
|
||||
json!({
|
||||
"name": name,
|
||||
"version": c.version,
|
||||
"installed": crate::install::installed_version(&bin, name),
|
||||
"license": c.license,
|
||||
"homepage": c.homepage,
|
||||
"bundled": c.bundled,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
Response::ok(json!(list))
|
||||
}
|
||||
|
||||
Request::ComponentsInstall { names } => {
|
||||
// Programs the service runs as SYSTEM: an administrator's call, whatever the scopes.
|
||||
if !peer.admin {
|
||||
return Response::err("installing components needs an administrator");
|
||||
}
|
||||
let manifest = ps_core::components::manifest();
|
||||
let wanted: Vec<String> = if names.is_empty() {
|
||||
manifest.components.iter().filter(|(_, c)| !c.bundled).map(|(n, _)| n.clone()).collect()
|
||||
} else {
|
||||
names
|
||||
};
|
||||
let (bin, cache, routes) = {
|
||||
let s = shared.lock().await;
|
||||
(s.paths().bin(), s.paths().root.join("downloads"), s.fetch_routes(true))
|
||||
};
|
||||
let mut results = Vec::new();
|
||||
for name in wanted {
|
||||
let Some(comp) = manifest.components.get(&name) else {
|
||||
results.push(json!({ "name": name, "error": "no such component" }));
|
||||
continue;
|
||||
};
|
||||
// What runs from it must let go of its files first.
|
||||
shared.lock().await.sup.stop_all().await;
|
||||
let r = crate::install::install(&bin, &name, comp, &routes, &cache).await;
|
||||
results.push(match r {
|
||||
Ok(()) => json!({ "name": name, "version": comp.version }),
|
||||
Err(e) => json!({ "name": name, "error": format!("{e:#}") }),
|
||||
});
|
||||
}
|
||||
let _ = shared.lock().await.apply().await;
|
||||
Response::ok(json!(results))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user