aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
40
akode-rs/mxc-sandbox/src/native.rs
Normal file
40
akode-rs/mxc-sandbox/src/native.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
//! Run an already prepared MXC request with inherited stdio and job ownership.
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::ensure;
|
||||
use mxc_sdk::mxc_common::logger::Logger;
|
||||
use mxc_sdk::mxc_common::logger::Mode;
|
||||
use mxc_sdk::mxc_common::models::ExecutionRequest;
|
||||
use mxc_sdk::mxc_common::sandbox_process::SandboxBackend;
|
||||
use mxc_sdk::mxc_common::sandbox_process::StdioMode;
|
||||
use mxc_sdk::process_container_common::base_container_runner::BaseContainerRunner;
|
||||
|
||||
// The ETW functions used by tracelogging are documented Advapi32 exports on
|
||||
// both Windows toolchains; 1.2.3 leaves their import library to the application.
|
||||
#[link(name = "advapi32")]
|
||||
unsafe extern "system" {}
|
||||
|
||||
pub(super) fn launch(request: &ExecutionRequest) -> Result<i32> {
|
||||
ensure!(
|
||||
!request
|
||||
.policy
|
||||
.capabilities
|
||||
.iter()
|
||||
.any(|capability| capability.eq_ignore_ascii_case("permissiveLearningMode")),
|
||||
"MXC native launch does not support permissiveLearningMode"
|
||||
);
|
||||
if !request.policy.denied_paths.is_empty() {
|
||||
ensure!(
|
||||
BaseContainerRunner::supports_native_denied_paths(),
|
||||
"this Windows build cannot enforce native MXC deny paths"
|
||||
);
|
||||
}
|
||||
let mut logger = Logger::new(Mode::Buffer);
|
||||
let mut child = BaseContainerRunner::new()
|
||||
.spawn(request, &mut logger, StdioMode::Inherit)
|
||||
.map_err(|error| anyhow::anyhow!("{}", error.error_message))?;
|
||||
// Do not publish the SDK diagnostic buffer: it may contain command or
|
||||
// environment data. This wrapper emits only the resulting launch error.
|
||||
child.wait().context("waiting for the MXC command")
|
||||
}
|
||||
Reference in New Issue
Block a user