#[cfg(any(target_os = "linux", target_os = "macos"))]
use crate::error::Error;
use crate::error::Result;
use crate::policy::AccessPolicy;
use std::ffi::{OsStr, OsString};
#[cfg(any(target_os = "linux", target_os = "macos"))]
use std::os::unix::process::CommandExt;
use std::path::Path;
#[cfg(any(target_os = "linux", target_os = "macos"))]
use std::process::Command;
pub(crate) trait Backend {
fn execute(
&self,
policy: &AccessPolicy,
policy_base: &Path,
command: &OsStr,
args: &[OsString],
) -> Result<()>;
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub(crate) fn exec_unix_command(command: &OsStr, args: &[OsString]) -> Result<()> {
let error = Command::new(command).args(args).exec();
Err(Error::Exec {
command: command.to_os_string(),
source: error,
})
}
#[cfg(target_os = "linux")]
pub(crate) use crate::linux::LinuxBackend as PlatformBackend;
#[cfg(target_os = "macos")]
pub(crate) use crate::macos::MacosBackend as PlatformBackend;
#[cfg(target_os = "windows")]
pub(crate) use crate::windows::WindowsBackend as PlatformBackend;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub(crate) use crate::fallback::FallbackBackend as PlatformBackend;