Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ uudoc = [
"dep:regex",
"dep:zip",
]
selinux = ["dep:selinux"]
## features
## Optional feature for stdbuf
# "feat_external_libstdbuf" == use an external libstdbuf.so for stdbuf instead of embedding it
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ name = "cp_bench"
harness = false

[features]
feat_selinux = ["selinux", "uucore/selinux"]
selinux = ["dep:selinux", "uucore/selinux"]
feat_acl = ["exacl"]
2 changes: 1 addition & 1 deletion src/uu/id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ name = "id"
path = "src/main.rs"

[features]
feat_selinux = ["selinux"]
selinux = ["dep:selinux"]
smack = ["uucore/smack"]
2 changes: 1 addition & 1 deletion src/uu/ls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ name = "ls_bench"
harness = false

[features]
feat_selinux = ["selinux", "uucore/selinux"]
selinux = ["dep:selinux", "uucore/selinux"]
smack = ["uucore/smack"]
5 changes: 1 addition & 4 deletions tests/by-util/test_chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (jargon) xattributes
#![allow(clippy::missing_errors_doc, clippy::similar_names)]
#![cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#![cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]

use std::ffi::CString;
use std::path::Path;
Expand Down
62 changes: 13 additions & 49 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#[cfg(unix)]
use rstest::rstest;
use uucore::display::Quotable;
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
use uucore::selinux::get_getfattr_output;
use uutests::util::TestScenario;
use uutests::{at_and_ucmd, new_ucmd, path_concat, util_name};
Expand Down Expand Up @@ -1831,7 +1828,7 @@ fn test_cp_preserve_xattr() {

#[test]
#[cfg(all(
not(feature = "feat_selinux"),
not(feature = "selinux"),
any(target_os = "linux", target_os = "android")
))]
fn test_cp_preserve_all_context_fails_on_non_selinux() {
Expand Down Expand Up @@ -6777,10 +6774,7 @@ fn test_cp_from_stream_permission() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_selinux() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
Expand All @@ -6805,10 +6799,7 @@ fn test_cp_selinux() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_selinux_invalid() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
Expand All @@ -6832,10 +6823,7 @@ fn test_cp_selinux_invalid() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_preserve_selinux() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
Expand Down Expand Up @@ -6873,10 +6861,7 @@ fn test_cp_preserve_selinux() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_preserve_selinux_admin_context() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
Expand Down Expand Up @@ -6935,10 +6920,7 @@ fn test_cp_preserve_selinux_admin_context() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_selinux_context_priority() {
// This test verifies that -Z takes priority over --context

Expand Down Expand Up @@ -7018,10 +7000,7 @@ fn test_cp_selinux_context_priority() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_selinux_empty_context() {
// This test verifies that --context without a value works like -Z

Expand Down Expand Up @@ -7067,10 +7046,7 @@ fn test_cp_selinux_empty_context() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_selinux_recursive() {
// Test SELinux context preservation in recursive directory copies

Expand Down Expand Up @@ -7124,10 +7100,7 @@ fn test_cp_selinux_recursive() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_preserve_context_root() {
use uutests::util::run_ucmd_as_root;
let scene = TestScenario::new(util_name!());
Expand Down Expand Up @@ -7830,10 +7803,7 @@ fn test_cp_gnu_preserve_mode() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_a_z_overrides_context() {
// Verifies -aZ succeeds (-Z overrides implicit --preserve=context from -a)
use std::path::Path;
Expand All @@ -7851,10 +7821,7 @@ fn test_cp_a_z_overrides_context() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_a_preserves_context() {
use std::path::Path;
use uucore::selinux::{get_selinux_security_context, set_selinux_security_context};
Expand All @@ -7877,10 +7844,7 @@ fn test_cp_a_preserves_context() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_cp_preserve_context_with_z_fails() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("src");
Expand Down
6 changes: 3 additions & 3 deletions tests/by-util/test_dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util::TestScenario;
#[cfg(all(unix, not(feature = "feat_selinux")))]
#[cfg(all(unix, not(feature = "selinux")))]
use uutests::util::run_ucmd_as_root_with_stdin_stdout;
#[cfg(all(not(windows), feature = "printf"))]
use uutests::util::{UCommand, get_tests_binary};
Expand Down Expand Up @@ -1608,7 +1608,7 @@ fn test_nocache_file() {

#[test]
#[cfg(unix)]
#[cfg(not(feature = "feat_selinux"))]
#[cfg(not(feature = "selinux"))]
// Disabled on SELinux for now
fn test_skip_past_dev() {
// NOTE: This test intends to trigger code which can only be reached with root permissions.
Expand All @@ -1633,7 +1633,7 @@ fn test_skip_past_dev() {

#[test]
#[cfg(unix)]
#[cfg(not(feature = "feat_selinux"))]
#[cfg(not(feature = "selinux"))]
fn test_seek_past_dev() {
// NOTE: This test intends to trigger code which can only be reached with root permissions.
let ts = TestScenario::new(util_name!());
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ fn test_type_option() {

#[test]
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "windows")))] // FIXME: fix test for FreeBSD, OpenBSD & Win
#[cfg(not(feature = "feat_selinux"))]
#[cfg(not(feature = "selinux"))]
fn test_type_option_with_file() {
let fs_type = new_ucmd!()
.args(&["--output=fstype", "."])
Expand Down
12 changes: 3 additions & 9 deletions tests/by-util/test_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_id_no_specified_user() {
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
let mut exp_stdout = exp_result.stdout_str().to_string();

#[cfg(not(feature = "feat_selinux"))]
#[cfg(not(feature = "selinux"))]
{
// NOTE: strip 'context' part from exp_stdout if selinux not enabled:
// example:
Expand Down Expand Up @@ -383,10 +383,7 @@ fn test_id_zero() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_id_context() {
if !uucore::selinux::is_selinux_enabled() {
println!("test skipped: Kernel has no support for SElinux context");
Expand Down Expand Up @@ -456,10 +453,7 @@ fn test_id_no_specified_user_posixly() {
result.success();
}

#[cfg(all(
any(target_os = "linux", target_os = "android"),
feature = "feat_selinux"
))]
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
{
if uucore::selinux::is_selinux_enabled() {
let result = ts.ucmd().succeeds();
Expand Down
20 changes: 4 additions & 16 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use std::process;
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::thread::sleep;
use uucore::process::{getegid, geteuid};
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
use uucore::selinux::get_getfattr_output;
use uutests::at_and_ucmd;
use uutests::new_ucmd;
Expand Down Expand Up @@ -2361,10 +2358,7 @@ fn test_install_no_target_basic() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_selinux() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
Expand Down Expand Up @@ -2413,10 +2407,7 @@ fn test_selinux() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_selinux_invalid_args() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
Expand Down Expand Up @@ -2449,10 +2440,7 @@ fn test_selinux_invalid_args() {
}

#[test]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
fn test_selinux_default_context() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
Expand Down
Loading
Loading