ksud: ensure ksud context when install (#356)

Incorrect se context will make module system broken
This commit is contained in:
Ylarod
2023-04-07 12:46:59 +08:00
committed by GitHub
parent 4d6fafd778
commit ffe3e68c35
2 changed files with 4 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ use log::{info, warn};
use std::{collections::HashMap, path::Path}; use std::{collections::HashMap, path::Path};
use crate::{ use crate::{
assets, defs, mount, assets, defs, mount, restorecon,
utils::{self, ensure_clean_dir, ensure_dir_exists}, utils::{self, ensure_clean_dir, ensure_dir_exists},
}; };
@@ -246,7 +246,7 @@ pub fn daemon() -> Result<()> {
pub fn install() -> Result<()> { pub fn install() -> Result<()> {
ensure_dir_exists(defs::ADB_DIR)?; ensure_dir_exists(defs::ADB_DIR)?;
std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?; std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?;
restorecon::setcon(defs::DAEMON_PATH, restorecon::ADB_CON)?;
// install binary assets // install binary assets
assets::ensure_binaries().with_context(|| "Failed to extract assets")?; assets::ensure_binaries().with_context(|| "Failed to extract assets")?;

View File

@@ -7,8 +7,8 @@ use anyhow::{Context, Ok};
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use extattr::{setxattr, Flags as XattrFlags}; use extattr::{setxattr, Flags as XattrFlags};
const SYSTEM_CON: &str = "u:object_r:system_file:s0"; pub const SYSTEM_CON: &str = "u:object_r:system_file:s0";
const _ADB_CON: &str = "u:object_r:adb_data_file:s0"; pub const ADB_CON: &str = "u:object_r:adb_data_file:s0";
const SELINUX_XATTR: &str = "security.selinux"; const SELINUX_XATTR: &str = "security.selinux";
pub fn setcon<P: AsRef<Path>>(path: P, con: &str) -> Result<()> { pub fn setcon<P: AsRef<Path>>(path: P, con: &str) -> Result<()> {