Skip to content

Commit 204954a

Browse files
committed
mkdir: add selinux/smack cfg alias
1 parent 7293e32 commit 204954a

4 files changed

Lines changed: 19 additions & 2 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/mkdir/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ path = "src/mkdir.rs"
1919
test = false
2020
doctest = false
2121

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

src/uu/mkdir/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/mkdir/src/mkdir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ fn create_single_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<(
331331
}
332332

333333
// Apply SELinux context if requested
334-
#[cfg(all(feature = "selinux", any(target_os = "android", target_os = "linux")))]
334+
#[cfg(selinux)]
335335
if config.set_security_context && uucore::selinux::is_selinux_enabled() {
336336
if let Err(e) = uucore::selinux::set_selinux_security_context(path, config.context)
337337
{
@@ -341,7 +341,7 @@ fn create_single_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<(
341341
}
342342

343343
// Apply SMACK context if requested
344-
#[cfg(all(feature = "smack", target_os = "linux"))]
344+
#[cfg(smack)]
345345
if config.set_security_context {
346346
uucore::smack::set_smack_label_and_cleanup(path, config.context, |p| {
347347
std::fs::remove_dir(p)

0 commit comments

Comments
 (0)