ksud: Add userspace cli to load module

This commit is contained in:
tiann
2023-01-04 14:41:55 +08:00
parent 3f9b1cb74b
commit 35aae8b0eb
13 changed files with 1554 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
use anyhow::ensure;
use anyhow::Ok;
use anyhow::Result;
use subprocess::Exec;
const SYSTEM_CON: &str = "u:object_r:system_file:s0";
const _ADB_CON: &str = "u:object_r:adb_data_file:s0";
pub fn restore_syscon(dir: &str) -> Result<()> {
// todo use libselinux directly
let cmd = format!("chcon -R {} {}", SYSTEM_CON, dir);
let result = Exec::shell(cmd).join()?;
ensure!(result.success(), "chcon for: {} failed.", dir);
Ok(())
}