selinux tip, remove rust dep 'selinux'
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -1935,10 +1935,10 @@ pub fn is_support_multi_ui_session(version: String) -> SyncReturn<bool> {
|
||||
SyncReturn(crate::common::is_support_multi_ui_session(&version))
|
||||
}
|
||||
|
||||
pub fn is_selinux_enabled() -> SyncReturn<bool> {
|
||||
pub fn is_selinux_enforcing() -> SyncReturn<bool> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
SyncReturn(crate::platform::linux::is_selinux_enabled())
|
||||
SyncReturn(crate::platform::linux::is_selinux_enforcing())
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
|
||||
@@ -1371,9 +1371,19 @@ pub fn is_x11() -> bool {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_selinux_enabled() -> bool {
|
||||
match selinux::kernel_support() {
|
||||
selinux::KernelSupport::Unsupported => false,
|
||||
_ => selinux::current_mode() == selinux::SELinuxMode::Enforcing,
|
||||
pub fn is_selinux_enforcing() -> bool {
|
||||
match run_cmds("getenforce") {
|
||||
Ok(output) => output.trim() == "Enforcing",
|
||||
Err(_) => match run_cmds("sestatus") {
|
||||
Ok(output) => {
|
||||
for line in output.lines() {
|
||||
if line.contains("Current mode:") {
|
||||
return line.contains("enforcing");
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
Err(_) => false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user