Skip to content

Commit aac5d86

Browse files
committed
fix(id): add feat_selinux cfg alias
1 parent 5bf2418 commit aac5d86

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

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/id/Cargo.toml

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

21+
[build-dependencies]
22+
cfg_aliases.workspace = true
23+
2124
[dependencies]
2225
clap = { workspace = true }
2326
uucore = { workspace = true, features = ["entries", "process"] }

src/uu/id/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 = "feat_selinux", any(target_os = "android", target_os = "linux")) },
11+
}
12+
}

src/uu/id/src/id.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ macro_rules! cstr2cow {
6363
}
6464

6565
fn get_context_help_text() -> String {
66-
#[cfg(not(any(feature = "selinux", feature = "smack")))]
66+
#[cfg(not(any(selinux, feature = "smack")))]
6767
return translate!("id-context-help-disabled");
68-
#[cfg(any(feature = "selinux", feature = "smack"))]
68+
#[cfg(any(selinux, feature = "smack"))]
6969
return translate!("id-context-help-enabled");
7070
}
7171

@@ -99,7 +99,7 @@ struct State {
9999
rflag: bool, // --real
100100
zflag: bool, // --zero
101101
cflag: bool, // --context
102-
#[cfg(feature = "selinux")]
102+
#[cfg(selinux)]
103103
selinux_supported: bool,
104104
#[cfg(feature = "smack")]
105105
smack_supported: bool,
@@ -141,7 +141,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
141141
zflag: matches.get_flag(options::OPT_ZERO),
142142
cflag: matches.get_flag(options::OPT_CONTEXT),
143143

144-
#[cfg(feature = "selinux")]
144+
#[cfg(selinux)]
145145
selinux_supported: uucore::selinux::is_selinux_enabled(),
146146
#[cfg(feature = "smack")]
147147
smack_supported: uucore::smack::is_smack_enabled(),
@@ -179,7 +179,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
179179

180180
if state.cflag {
181181
// SELinux context
182-
#[cfg(feature = "selinux")]
182+
#[cfg(selinux)]
183183
if state.selinux_supported {
184184
if let Ok(context) = selinux::SecurityContext::current(false) {
185185
let bytes = context.as_bytes();
@@ -702,7 +702,7 @@ fn id_print(state: &State, groups: &[u32]) -> io::Result<()> {
702702
.join(",")
703703
)?;
704704

705-
#[cfg(feature = "selinux")]
705+
#[cfg(selinux)]
706706
if state.selinux_supported
707707
&& !state.user_specified
708708
&& std::env::var_os("POSIXLY_CORRECT").is_none()

0 commit comments

Comments
 (0)