Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ itertools.workspace = true
jiff = { workspace = true, optional = true }
phf.workspace = true
regex = { workspace = true, optional = true }
selinux = { workspace = true, optional = true }
textwrap.workspace = true
uucore.workspace = true
zip = { workspace = true, optional = true }
Expand Down Expand Up @@ -714,6 +713,7 @@ rstest_reuse.workspace = true

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
rustix.workspace = true
selinux = { workspace = true, optional = true }

# this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)"
# factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }
Expand Down
4 changes: 3 additions & 1 deletion src/uu/cp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ doctest = false
clap = { workspace = true }
filetime = { workspace = true }
libc = { workspace = true }
selinux = { workspace = true, optional = true }
uucore = { workspace = true, features = [
"backup-control",
"buf-copy",
Expand All @@ -41,6 +40,9 @@ thiserror = { workspace = true }
fluent = { workspace = true }
rustix = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }

[target.'cfg(unix)'.dependencies]
exacl = { workspace = true, optional = true }
nix = { workspace = true, features = ["fs"] }
Expand Down
4 changes: 3 additions & 1 deletion src/uu/id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ doctest = false
clap = { workspace = true }
rustix = { workspace = true }
uucore = { workspace = true, features = ["entries", "process"] }
selinux = { workspace = true, optional = true }
fluent = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }

[[bin]]
name = "id"
path = "src/main.rs"
Expand Down
4 changes: 3 additions & 1 deletion src/uu/install/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ path = "src/install.rs"
clap = { workspace = true }
filetime = { workspace = true }
file_diff = { workspace = true }
selinux = { workspace = true, optional = true }
thiserror = { workspace = true }
uucore = { workspace = true, default-features = true, features = [
"backup-control",
Expand All @@ -34,6 +33,9 @@ uucore = { workspace = true, default-features = true, features = [
] }
fluent = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }

[features]
selinux = ["dep:selinux", "uucore/selinux"]

Expand Down
4 changes: 3 additions & 1 deletion src/uu/ls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ clap = { workspace = true, features = ["env"] }
glob = { workspace = true }
lscolors = { workspace = true }
rustc-hash = { workspace = true }
selinux = { workspace = true, optional = true }
terminal_size = { workspace = true }
thiserror = { workspace = true }
uucore = { workspace = true, features = [
Expand All @@ -45,6 +44,9 @@ uucore = { workspace = true, features = [
uutils_term_grid = { workspace = true }
fluent = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }

# hostname crate does not support WASI (no OS-level hostname API)
[target.'cfg(not(target_os = "wasi"))'.dependencies]
hostname = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ sm3 = { workspace = true, optional = true }
crc-fast = { workspace = true, optional = true, features = ["std"] }
bigdecimal = { workspace = true, optional = true }
num-traits = { workspace = true, optional = true }
selinux = { workspace = true, optional = true }

# icu stuff
icu_calendar = { workspace = true, optional = true, features = [
Expand Down Expand Up @@ -95,6 +94,9 @@ thiserror = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }

[target.'cfg(unix)'.dependencies]
nix = { workspace = true, features = [
"dir",
Expand Down
5 changes: 4 additions & 1 deletion tests/by-util/test_chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
// file that was distributed with this source code.
// spell-checker:ignore (jargon) xattributes
#![allow(clippy::missing_errors_doc, clippy::similar_names)]
#![cfg(feature = "feat_selinux")]
#![cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]

use std::ffi::CString;
use std::path::Path;
Expand Down
50 changes: 40 additions & 10 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#[cfg(unix)]
use rstest::rstest;
use uucore::display::Quotable;
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -6771,7 +6774,10 @@ fn test_cp_from_stream_permission() {
}

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

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -6858,7 +6867,10 @@ fn test_cp_preserve_selinux() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -6917,7 +6929,10 @@ fn test_cp_preserve_selinux_admin_context() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -6997,7 +7012,10 @@ fn test_cp_selinux_context_priority() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -7043,7 +7061,10 @@ fn test_cp_selinux_empty_context() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -7097,7 +7118,10 @@ fn test_cp_selinux_recursive() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -7800,7 +7824,10 @@ fn test_cp_gnu_preserve_mode() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -7818,7 +7845,10 @@ fn test_cp_a_z_overrides_context() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 Down
5 changes: 4 additions & 1 deletion tests/by-util/test_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ fn test_id_zero() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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
20 changes: 16 additions & 4 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use std::process;
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::thread::sleep;
use uucore::process::{getegid, geteuid};
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -2334,7 +2337,10 @@ fn test_install_no_target_basic() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -2383,7 +2389,10 @@ fn test_selinux() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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 @@ -2416,7 +2425,10 @@ fn test_selinux_invalid_args() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_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
35 changes: 28 additions & 7 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4656,7 +4656,10 @@ fn test_ls_dangling_symlinks() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
fn test_ls_context1() {
if !uucore::selinux::is_selinux_enabled() {
println!("test skipped: Kernel has no support for SElinux context");
Expand All @@ -4671,7 +4674,10 @@ fn test_ls_context1() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
fn test_ls_context2() {
if !uucore::selinux::is_selinux_enabled() {
println!("test skipped: Kernel has no support for SElinux context");
Expand All @@ -4687,7 +4693,10 @@ fn test_ls_context2() {
}

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
fn test_ls_context_long() {
if !uucore::selinux::is_selinux_enabled() {
return;
Expand All @@ -4706,7 +4715,10 @@ fn test_ls_context_long() {
}

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

/// Helper function to validate `SELinux` context format
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
fn validate_selinux_context(context: &str) {
assert!(
context.contains(':'),
Expand All @@ -4751,7 +4766,10 @@ fn validate_selinux_context(context: &str) {
}

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

#[test]
#[cfg(feature = "feat_selinux")]
#[cfg(all(
feature = "feat_selinux",
any(target_os = "linux", target_os = "android")
))]
fn test_ls_selinux_context_indicator() {
if !uucore::selinux::is_selinux_enabled() {
println!("test skipped: Kernel has no support for SElinux context");
Expand Down
Loading
Loading