Skip to content

Commit 598222a

Browse files
committed
ls: add selinux/smack cfg alias
1 parent d712bc1 commit 598222a

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/ls/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ workspace = true
2020
[lib]
2121
path = "src/ls.rs"
2222

23+
[build-dependencies]
24+
cfg_aliases.workspace = true
25+
2326
[dependencies]
2427
ansi-width = { workspace = true }
2528
clap = { workspace = true, features = ["env"] }

src/uu/ls/build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This file is part of the uutils coreutils package.
2+
//
3+
// For the full copyright and license information, please view the LICENSE
4+
// file that was distributed with this source code.
5+
6+
use cfg_aliases::cfg_aliases;
7+
8+
pub fn main() {
9+
cfg_aliases! {
10+
selinux: { all(feature = "selinux", any(target_os = "android", target_os = "linux")) },
11+
smack: { all(feature = "smack", target_os = "linux") },
12+
}
13+
}

src/uu/ls/src/ls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ pub struct Config {
375375
time_format_recent: String, // Time format for recent dates
376376
time_format_older: Option<String>, // Time format for older dates (optional, if not present, time_format_recent is used)
377377
context: bool,
378-
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
378+
#[cfg(selinux)]
379379
selinux_supported: bool,
380-
#[cfg(all(feature = "smack", target_os = "linux"))]
380+
#[cfg(smack)]
381381
smack_supported: bool,
382382
group_directories_first: bool,
383383
line_ending: LineEnding,
@@ -1237,9 +1237,9 @@ impl Config {
12371237
time_format_recent,
12381238
time_format_older,
12391239
context,
1240-
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
1240+
#[cfg(selinux)]
12411241
selinux_supported: uucore::selinux::is_selinux_enabled(),
1242-
#[cfg(all(feature = "smack", target_os = "linux"))]
1242+
#[cfg(smack)]
12431243
smack_supported: uucore::smack::is_smack_enabled(),
12441244
group_directories_first: options.get_flag(options::GROUP_DIRECTORIES_FIRST),
12451245
line_ending: LineEnding::from_zero_flag(options.get_flag(options::ZERO)),
@@ -3595,7 +3595,7 @@ fn get_security_context<'a>(
35953595
}
35963596
}
35973597

3598-
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
3598+
#[cfg(selinux)]
35993599
if config.selinux_supported {
36003600
match selinux::SecurityContext::of_path(path, must_dereference, false) {
36013601
Err(_r) => {
@@ -3633,7 +3633,7 @@ fn get_security_context<'a>(
36333633
}
36343634
}
36353635

3636-
#[cfg(all(feature = "smack", target_os = "linux"))]
3636+
#[cfg(smack)]
36373637
if config.smack_supported {
36383638
// For SMACK, use the path to get the label
36393639
// If must_dereference is true, we follow the symlink

0 commit comments

Comments
 (0)