mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
selinux: adjust more error messages
This commit is contained in:
parent
2e34d94e17
commit
832dd495bf
7 changed files with 13 additions and 9 deletions
|
@ -608,7 +608,7 @@ fn process_file(
|
|||
if result.is_ok() {
|
||||
if options.verbose {
|
||||
println!(
|
||||
"{}: Changing security context of: {}",
|
||||
"{}: changing security context of {}",
|
||||
uucore::util_name(),
|
||||
file_full_name.quote()
|
||||
);
|
||||
|
|
|
@ -1710,7 +1710,7 @@ pub(crate) fn copy_attributes(
|
|||
if let Some(context) = context {
|
||||
if let Err(e) = context.set_for_path(dest, false, false) {
|
||||
return Err(Error::Error(format!(
|
||||
"failed to set security context for {}: {e}",
|
||||
"failed to set the security context of {}: {e}",
|
||||
dest.display()
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -74,10 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
uucore::selinux::set_selinux_security_context(Path::new(&f), context)
|
||||
{
|
||||
let _ = fs::remove_file(f);
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("failed to set SELinux security context: {e}"),
|
||||
));
|
||||
return Err(USimpleError::new(1, e.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
|
|||
) {
|
||||
// if it fails, delete the file
|
||||
let _ = std::fs::remove_dir(file_name);
|
||||
eprintln!("failed to set SELinux security context: {}", e);
|
||||
eprintln!("{}: {}", uucore::util_name(), e);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6315,7 +6315,7 @@ fn test_cp_selinux_invalid() {
|
|||
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||
.arg(TEST_HELLO_WORLD_DEST)
|
||||
.fails()
|
||||
.stderr_contains("Failed to");
|
||||
.stderr_contains("failed to");
|
||||
if at.file_exists(TEST_HELLO_WORLD_DEST) {
|
||||
at.remove(TEST_HELLO_WORLD_DEST);
|
||||
}
|
||||
|
|
|
@ -411,7 +411,7 @@ fn test_selinux_invalid() {
|
|||
.arg(at.plus_as_string(dest))
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains("Failed to set default file creation context to 'testtest':");
|
||||
.stderr_contains("failed to set default file creation context to 'testtest':");
|
||||
// invalid context, so, no directory
|
||||
assert!(!at.dir_exists(dest));
|
||||
}
|
||||
|
|
|
@ -347,3 +347,10 @@ sed -i 's/not supported/unexpected argument/' tests/mv/mv-exchange.sh
|
|||
# /nix/store/xxxxxxxxxxxx...xxxx/bin/tr
|
||||
# We just replace the references to `/usr/bin/tr` with the result of `$(which tr)`
|
||||
sed -i 's/\/usr\/bin\/tr/$(which tr)/' tests/init.sh
|
||||
|
||||
# upstream doesn't having the program name in the error message
|
||||
# but we do. We should keep it that way.
|
||||
sed -i 's/echo "changing security context/echo "chcon: changing security context/' tests/chcon/chcon.sh
|
||||
|
||||
# we produce a different error message
|
||||
sed -i -e "s|-e 's/ Not supported$//'|-e 's/ context_new() failed$//'|g" tests/mkdir/selinux.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue