#![deny(unsafe_op_in_unsafe_fn)]
#![warn(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(docsrs, feature(doc_cfg))]
mod error;
pub use error::{AcError, Result};
pub mod acl;
pub mod capability;
#[cfg(feature = "introspection")]
pub mod diag;
pub mod launch;
#[cfg(feature = "net")]
pub mod net;
pub mod profile;
pub mod sid;
pub mod token;
pub mod util;
pub(crate) mod ffi;
pub use capability::{KnownCapability, SecurityCapabilities, SecurityCapabilitiesBuilder};
pub use launch::{JobLimits, LaunchOptions, Launched, StdioConfig, launch_in_container};
#[cfg(windows)]
pub use launch::{LaunchedIo, launch_in_container_with_io};
pub use profile::{AppContainerProfile, derive_sid_from_name};
pub use sid::AppContainerSid;
pub fn supports_lpac() -> Result<()> {
#[cfg(windows)]
{
if let Ok(val) = std::env::var("RAPPCT_TEST_LPAC_STATUS") {
match val.as_str() {
"ok" => return Ok(()),
"unsupported" => return Err(AcError::UnsupportedLpac),
_ => {}
}
}
#[repr(C)]
struct OsVersionInfoW {
size: u32,
major: u32,
minor: u32,
build: u32,
platform: u32,
csd: [u16; 128],
}
#[link(name = "ntdll")]
unsafe extern "system" {
fn RtlGetVersion(info: *mut OsVersionInfoW) -> i32;
}
unsafe {
let mut v = OsVersionInfoW {
size: std::mem::size_of::<OsVersionInfoW>() as u32,
major: 0,
minor: 0,
build: 0,
platform: 0,
csd: [0u16; 128],
};
let st = RtlGetVersion(&mut v as *mut _);
if st != 0 {
return Err(AcError::UnsupportedLpac);
}
if v.major < 10 {
return Err(AcError::UnsupportedLpac);
}
if v.build < 15063 {
return Err(AcError::UnsupportedLpac);
}
Ok(())
}
}
#[cfg(not(windows))]
{
Err(AcError::UnsupportedPlatform)
}
}