Skip to content

Commit 2108d90

Browse files
committed
selinux: use the uucore function
1 parent c764678 commit 2108d90

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::is_selinux_enabled()
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
@@ -1123,7 +1123,7 @@ impl Config {
11231123
selinux_supported: {
11241124
#[cfg(feature = "selinux")]
11251125
{
1126-
selinux::kernel_support() != selinux::KernelSupport::Unsupported
1126+
uucore::selinux::is_selinux_enabled()
11271127
}
11281128
#[cfg(not(feature = "selinux"))]
11291129
{

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::is_selinux_enabled() {
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::is_selinux_enabled() {
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::is_selinux_enabled() {
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::is_selinux_enabled() {
461459
println!("test skipped: Kernel has no support for SElinux context");
462460
} else {
463461
let result = ts.ucmd().succeeds();

0 commit comments

Comments
 (0)