Skip to content

Commit 832dd49

Browse files
committed
selinux: adjust more error messages
1 parent 2e34d94 commit 832dd49

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

src/uu/chcon/src/chcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn process_file(
608608
if result.is_ok() {
609609
if options.verbose {
610610
println!(
611-
"{}: Changing security context of: {}",
611+
"{}: changing security context of {}",
612612
uucore::util_name(),
613613
file_full_name.quote()
614614
);

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ pub(crate) fn copy_attributes(
17101710
if let Some(context) = context {
17111711
if let Err(e) = context.set_for_path(dest, false, false) {
17121712
return Err(Error::Error(format!(
1713-
"failed to set security context for {}: {e}",
1713+
"failed to set the security context of {}: {e}",
17141714
dest.display()
17151715
)));
17161716
}

src/uu/mkfifo/src/mkfifo.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
7474
uucore::selinux::set_selinux_security_context(Path::new(&f), context)
7575
{
7676
let _ = fs::remove_file(f);
77-
return Err(USimpleError::new(
78-
1,
79-
format!("failed to set SELinux security context: {e}"),
80-
));
77+
return Err(USimpleError::new(1, e.to_string()));
8178
}
8279
}
8380
}

src/uu/mknod/src/mknod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
9898
) {
9999
// if it fails, delete the file
100100
let _ = std::fs::remove_dir(file_name);
101-
eprintln!("failed to set SELinux security context: {}", e);
101+
eprintln!("{}: {}", uucore::util_name(), e);
102102
return 1;
103103
}
104104
}

tests/by-util/test_cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6315,7 +6315,7 @@ fn test_cp_selinux_invalid() {
63156315
.arg(TEST_HELLO_WORLD_SOURCE)
63166316
.arg(TEST_HELLO_WORLD_DEST)
63176317
.fails()
6318-
.stderr_contains("Failed to");
6318+
.stderr_contains("failed to");
63196319
if at.file_exists(TEST_HELLO_WORLD_DEST) {
63206320
at.remove(TEST_HELLO_WORLD_DEST);
63216321
}

tests/by-util/test_mkdir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ fn test_selinux_invalid() {
411411
.arg(at.plus_as_string(dest))
412412
.fails()
413413
.no_stdout()
414-
.stderr_contains("Failed to set default file creation context to 'testtest':");
414+
.stderr_contains("failed to set default file creation context to 'testtest':");
415415
// invalid context, so, no directory
416416
assert!(!at.dir_exists(dest));
417417
}

util/build-gnu.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,10 @@ sed -i 's/not supported/unexpected argument/' tests/mv/mv-exchange.sh
347347
# /nix/store/xxxxxxxxxxxx...xxxx/bin/tr
348348
# We just replace the references to `/usr/bin/tr` with the result of `$(which tr)`
349349
sed -i 's/\/usr\/bin\/tr/$(which tr)/' tests/init.sh
350+
351+
# upstream doesn't having the program name in the error message
352+
# but we do. We should keep it that way.
353+
sed -i 's/echo "changing security context/echo "chcon: changing security context/' tests/chcon/chcon.sh
354+
355+
# we produce a different error message
356+
sed -i -e "s|-e 's/ Not supported$//'|-e 's/ context_new() failed$//'|g" tests/mkdir/selinux.sh

0 commit comments

Comments
 (0)