Skip to content

Commit fc39c57

Browse files
committed
fix(mknod): add feat_smack cfg alias
1 parent 174ba76 commit fc39c57

4 files changed

Lines changed: 23 additions & 7 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/mknod/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ workspace = true
1919
name = "uu_mknod"
2020
path = "src/mknod.rs"
2121

22+
[build-dependencies]
23+
cfg_aliases.workspace = true
24+
2225
[dependencies]
2326
clap = { workspace = true }
2427
uucore = { workspace = true, features = ["mode", "fs"] }

src/uu/mknod/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+
smack: { all(feature = "feat_smack", target_os = "linux") },
11+
}
12+
}

src/uu/mknod/src/mknod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ struct Config {
5757
dev: u64,
5858

5959
/// Set security context (SELinux/SMACK).
60-
#[cfg(any(feature = "selinux", feature = "smack"))]
60+
#[cfg(any(feature = "selinux", smack))]
6161
set_security_context: bool,
6262

6363
/// Specific security context (SELinux/SMACK).
64-
#[cfg(any(feature = "selinux", feature = "smack"))]
64+
#[cfg(any(feature = "selinux", smack))]
6565
context: Option<String>,
6666
}
6767

@@ -110,7 +110,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
110110
}
111111

112112
// Apply SMACK context if requested
113-
#[cfg(feature = "smack")]
113+
#[cfg(smack)]
114114
if config.set_security_context {
115115
if let Err(e) =
116116
uucore::smack::set_smack_label_and_cleanup(file_name, config.context.as_ref(), |p| {
@@ -146,9 +146,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
146146
.expect("Missing argument 'NAME'");
147147

148148
// Extract the security context related flags and options
149-
#[cfg(any(feature = "selinux", feature = "smack"))]
149+
#[cfg(any(feature = "selinux", smack))]
150150
let set_security_context = matches.get_flag(options::SECURITY_CONTEXT);
151-
#[cfg(any(feature = "selinux", feature = "smack"))]
151+
#[cfg(any(feature = "selinux", smack))]
152152
let context = matches.get_one::<String>(options::CONTEXT).cloned();
153153

154154
let dev = match (
@@ -177,9 +177,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
177177
file_type: file_type.clone(),
178178
use_umask,
179179
dev,
180-
#[cfg(any(feature = "selinux", feature = "smack"))]
180+
#[cfg(any(feature = "selinux", smack))]
181181
set_security_context: set_security_context || context.is_some(),
182-
#[cfg(any(feature = "selinux", feature = "smack"))]
182+
#[cfg(any(feature = "selinux", smack))]
183183
context,
184184
};
185185

0 commit comments

Comments
 (0)