Skip to content

Commit a268072

Browse files
committed
selinux: use the uucore function
1 parent 8487e12 commit a268072

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

src/uu/id/src/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
130130
selinux_supported: {
131131
#[cfg(feature = "selinux")]
132132
{
133-
selinux::kernel_support() != selinux::KernelSupport::Unsupported
133+
uucore::selinux::check_selinux_enabled().is_ok()
134134
}
135135
#[cfg(not(feature = "selinux"))]
136136
{

src/uu/ls/src/ls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ impl Config {
11121112
selinux_supported: {
11131113
#[cfg(feature = "selinux")]
11141114
{
1115-
selinux::kernel_support() != selinux::KernelSupport::Unsupported
1115+
uucore::selinux::check_selinux_enabled().is_ok()
11161116
}
11171117
#[cfg(not(feature = "selinux"))]
11181118
{

src/uu/runcon/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ path = "src/runcon.rs"
1919

2020
[dependencies]
2121
clap = { workspace = true }
22-
uucore = { workspace = true, features = ["entries", "fs", "perms"] }
22+
uucore = { workspace = true, features = ["entries", "fs", "perms", "selinux"] }
2323
selinux = { workspace = true }
2424
thiserror = { workspace = true }
2525
libc = { workspace = true }

src/uu/runcon/src/runcon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ fn set_next_exec_context(context: &OpaqueSecurityContext) -> Result<()> {
271271
}
272272

273273
fn get_plain_context(context: &OsStr) -> Result<OpaqueSecurityContext> {
274-
if selinux::kernel_support() == selinux::KernelSupport::Unsupported {
274+
if !uucore::selinux::check_selinux_enabled().is_ok() {
275275
return Err(Error::SELinuxNotEnabled);
276276
}
277277

@@ -342,7 +342,7 @@ fn get_custom_context(
342342
use OpaqueSecurityContext as OSC;
343343
type SetNewValueProc = fn(&OSC, &CStr) -> selinux::errors::Result<()>;
344344

345-
if selinux::kernel_support() == selinux::KernelSupport::Unsupported {
345+
if !uucore::selinux::check_selinux_enabled().is_ok() {
346346
return Err(Error::SELinuxNotEnabled);
347347
}
348348

tests/by-util/test_id.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,7 @@ fn test_id_zero() {
381381
#[test]
382382
#[cfg(feature = "feat_selinux")]
383383
fn test_id_context() {
384-
use selinux::{self, KernelSupport};
385-
if selinux::kernel_support() == KernelSupport::Unsupported {
384+
if !uucore::selinux::check_selinux_enabled().is_ok() {
386385
println!("test skipped: Kernel has no support for SElinux context");
387386
return;
388387
}
@@ -456,8 +455,7 @@ fn test_id_no_specified_user_posixly() {
456455
feature = "feat_selinux"
457456
))]
458457
{
459-
use selinux::{self, KernelSupport};
460-
if selinux::kernel_support() == KernelSupport::Unsupported {
458+
if !uucore::selinux::check_selinux_enabled().is_ok() {
461459
println!("test skipped: Kernel has no support for SElinux context");
462460
} else {
463461
let result = ts.ucmd().succeeds();

0 commit comments

Comments
 (0)