Skip to content

Commit 679010d

Browse files
committed
build: only use feat_selinux and remove selinux
1 parent e46aec7 commit 679010d

21 files changed

Lines changed: 62 additions & 50 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.

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ feat_acl = ["cp/feat_acl"]
5656
# * The selinux(-sys) crate requires `libselinux` headers and shared library to be accessible in the C toolchain at compile time.
5757
# * Running a uutils compiled with `feat_selinux` requires an SELinux enabled Kernel at run time.
5858
feat_selinux = [
59-
"cp/selinux",
59+
"cp/feat_selinux",
6060
"feat_require_selinux",
61-
"id/selinux",
62-
"install/selinux",
63-
"ls/selinux",
64-
"mkdir/selinux",
65-
"mkfifo/selinux",
66-
"mknod/selinux",
67-
"selinux",
68-
"stat/selinux",
61+
"id/feat_selinux",
62+
"install/feat_selinux",
63+
"ls/feat_selinux",
64+
"mkdir/feat_selinux",
65+
"mkfifo/feat_selinux",
66+
"mknod/feat_selinux",
67+
"stat/feat_selinux",
68+
"uutests/feat_selinux",
6969
]
7070
##
7171
## feature sets
@@ -532,6 +532,7 @@ num-prime.workspace = true
532532
pretty_assertions = "1.4.0"
533533
rand.workspace = true
534534
regex.workspace = true
535+
selinux = { workspace = true }
535536
sha1 = { workspace = true, features = ["std"] }
536537
tempfile.workspace = true
537538
time = { workspace = true, features = ["local-offset"] }

GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ TEST_NO_FAIL_FAST :=--no-fail-fast
288288
TEST_SPEC_FEATURE := test_unimplemented
289289
else ifeq ($(SELINUX_ENABLED),1)
290290
TEST_NO_FAIL_FAST :=
291-
TEST_SPEC_FEATURE := selinux
292-
BUILD_SPEC_FEATURE := selinux
291+
TEST_SPEC_FEATURE := feat_selinux
292+
BUILD_SPEC_FEATURE := feat_selinux
293293
endif
294294

295295
define TEST_BUSYBOX

src/uu/cp/src/cp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ impl Options {
11161116
}
11171117
}
11181118

1119-
#[cfg(not(feature = "selinux"))]
1119+
#[cfg(not(feature = "feat_selinux"))]
11201120
if let Preserve::Yes { required } = attributes.context {
11211121
let selinux_disabled_error = CpError::Error(translate!("cp-error-selinux-not-enabled"));
11221122
if required {
@@ -1713,7 +1713,7 @@ pub(crate) fn copy_attributes(
17131713
Ok(())
17141714
})?;
17151715

1716-
#[cfg(feature = "selinux")]
1716+
#[cfg(feature = "feat_selinux")]
17171717
handle_preserve(&attributes.context, || -> CopyResult<()> {
17181718
// Get the source context and apply it to the destination
17191719
if let Ok(context) = selinux::SecurityContext::of_path(source, false, false) {
@@ -2469,7 +2469,7 @@ fn copy_file(
24692469
copy_attributes(source, dest, &options.attributes)?;
24702470
}
24712471

2472-
#[cfg(feature = "selinux")]
2472+
#[cfg(feature = "feat_selinux")]
24732473
if options.set_selinux_context && uucore::selinux::is_selinux_enabled() {
24742474
// Set the given selinux permissions on the copied file.
24752475
if let Err(e) =

src/uu/id/src/id.rs

Lines changed: 12 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(feature = "selinux"))]
66+
#[cfg(not(feature = "feat_selinux"))]
6767
return translate!("id-context-help-disabled");
68-
#[cfg(feature = "selinux")]
68+
#[cfg(feature = "feat_selinux")]
6969
return translate!("id-context-help-enabled");
7070
}
7171

@@ -139,11 +139,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
139139
cflag: matches.get_flag(options::OPT_CONTEXT),
140140

141141
selinux_supported: {
142-
#[cfg(feature = "selinux")]
142+
#[cfg(feature = "feat_selinux")]
143143
{
144144
uucore::selinux::is_selinux_enabled()
145145
}
146-
#[cfg(not(feature = "selinux"))]
146+
#[cfg(not(feature = "feat_selinux"))]
147147
{
148148
false
149149
}
@@ -183,7 +183,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
183183
if state.cflag {
184184
return if state.selinux_supported {
185185
// print SElinux context and exit
186-
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
186+
#[cfg(all(
187+
any(target_os = "linux", target_os = "android"),
188+
feature = "feat_selinux"
189+
))]
187190
if let Ok(context) = selinux::SecurityContext::current(false) {
188191
let bytes = context.as_bytes();
189192
print!("{}{line_ending}", String::from_utf8_lossy(bytes));
@@ -644,7 +647,10 @@ fn id_print(state: &State, groups: &[u32]) {
644647
.join(",")
645648
);
646649

647-
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
650+
#[cfg(all(
651+
any(target_os = "linux", target_os = "android"),
652+
feature = "feat_selinux"
653+
))]
648654
if state.selinux_supported
649655
&& !state.user_specified
650656
&& std::env::var_os("POSIXLY_CORRECT").is_none()

src/uu/install/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ uucore = { workspace = true, default-features = true, features = [
3434
fluent = { workspace = true }
3535

3636
[features]
37-
selinux = ["uucore/selinux"]
37+
feat_selinux = ["uucore/selinux"]
3838

3939
[[bin]]
4040
name = "install"

src/uu/install/src/install.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use uucore::fs::dir_strip_dot_for_creation;
2727
use uucore::mode::get_umask;
2828
use uucore::perms::{Verbosity, VerbosityLevel, wrap_chown};
2929
use uucore::process::{getegid, geteuid};
30-
#[cfg(feature = "selinux")]
30+
#[cfg(feature = "feat_selinux")]
3131
use uucore::selinux::{contexts_differ, set_selinux_security_context};
3232
use uucore::translate;
3333
use uucore::{format_usage, show, show_error, show_if_err};
@@ -113,7 +113,7 @@ enum InstallError {
113113
#[error("{}", translate!("install-error-extra-operand", "operand" => .0.quote(), "usage" => .1.clone()))]
114114
ExtraOperand(String, String),
115115

116-
#[cfg(feature = "selinux")]
116+
#[cfg(feature = "feat_selinux")]
117117
#[error("{}", .0)]
118118
SelinuxContextFailed(String),
119119
}
@@ -482,7 +482,7 @@ fn directory(paths: &[OsString], b: &Behavior) -> UResult<()> {
482482
show_if_err!(chown_optional_user_group(path, b));
483483

484484
// Set SELinux context for directory if needed
485-
#[cfg(feature = "selinux")]
485+
#[cfg(feature = "feat_selinux")]
486486
show_if_err!(set_selinux_context(path, b));
487487
}
488488
// If the exit code was set, or show! has been called at least once
@@ -956,7 +956,7 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> UResult<()> {
956956
preserve_timestamps(from, to)?;
957957
}
958958

959-
#[cfg(feature = "selinux")]
959+
#[cfg(feature = "feat_selinux")]
960960
if b.preserve_context {
961961
uucore::selinux::preserve_security_context(from, to)
962962
.map_err(|e| InstallError::SelinuxContextFailed(e.to_string()))?;
@@ -1071,7 +1071,7 @@ fn need_copy(from: &Path, to: &Path, b: &Behavior) -> bool {
10711071
return true;
10721072
}
10731073

1074-
#[cfg(feature = "selinux")]
1074+
#[cfg(feature = "feat_selinux")]
10751075
if b.preserve_context && contexts_differ(from, to) {
10761076
return true;
10771077
}
@@ -1102,7 +1102,7 @@ fn need_copy(from: &Path, to: &Path, b: &Behavior) -> bool {
11021102
false
11031103
}
11041104

1105-
#[cfg(feature = "selinux")]
1105+
#[cfg(feature = "feat_selinux")]
11061106
fn set_selinux_context(path: &Path, behavior: &Behavior) -> UResult<()> {
11071107
if !behavior.preserve_context && behavior.context.is_some() {
11081108
// Use the provided context set by -Z/--context

src/uu/ls/src/ls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,11 +1083,11 @@ impl Config {
10831083
time_format_older,
10841084
context,
10851085
selinux_supported: {
1086-
#[cfg(feature = "selinux")]
1086+
#[cfg(feature = "feat_selinux")]
10871087
{
10881088
uucore::selinux::is_selinux_enabled()
10891089
}
1090-
#[cfg(not(feature = "selinux"))]
1090+
#[cfg(not(feature = "feat_selinux"))]
10911091
{
10921092
false
10931093
}
@@ -3278,7 +3278,7 @@ fn get_security_context(config: &Config, p_buf: &Path, must_dereference: bool) -
32783278
}
32793279
}
32803280
if config.selinux_supported {
3281-
#[cfg(feature = "selinux")]
3281+
#[cfg(feature = "feat_selinux")]
32823282
{
32833283
match selinux::SecurityContext::of_path(p_buf, must_dereference.to_owned(), false) {
32843284
Err(_r) => {
@@ -3302,7 +3302,7 @@ fn get_security_context(config: &Config, p_buf: &Path, must_dereference: bool) -
33023302
}
33033303
}
33043304
}
3305-
#[cfg(not(feature = "selinux"))]
3305+
#[cfg(not(feature = "feat_selinux"))]
33063306
{
33073307
substitute_string
33083308
}

src/uu/mkdir/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ uucore = { workspace = true, features = ["fs", "mode", "fsxattr"] }
2323
fluent = { workspace = true }
2424

2525
[features]
26-
selinux = ["uucore/selinux"]
26+
feat_selinux = ["uucore/selinux"]
2727

2828
[[bin]]
2929
name = "mkdir"

src/uu/mkdir/src/mkdir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn create_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<()> {
277277
chmod(path, new_mode)?;
278278

279279
// Apply SELinux context if requested
280-
#[cfg(feature = "selinux")]
280+
#[cfg(feature = "feat_selinux")]
281281
if config.set_selinux_context && uucore::selinux::is_selinux_enabled() {
282282
if let Err(e) = uucore::selinux::set_selinux_security_context(path, config.context)
283283
{

0 commit comments

Comments
 (0)