1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

ls: (--context/-Z) add support for invalid utf8

If security context byte slice contains invalid utf8:
* issue warning
* show replacement characters for invalid utf8 sequences
This commit is contained in:
Jan Scheer 2021-09-13 13:24:44 +02:00
parent e018a45b54
commit cd2153eac6
No known key found for this signature in database
GPG key ID: C62AD4C29E2B9828
2 changed files with 43 additions and 12 deletions

View file

@ -2282,7 +2282,23 @@ fn test_ls_dangling_symlinks() {
#[test]
#[cfg(feature = "feat_selinux")]
fn test_ls_context() {
fn test_ls_context1() {
use selinux::{self, KernelSupport};
if selinux::kernel_support() == KernelSupport::Unsupported {
println!("test skipped: Kernel has no support for SElinux context",);
return;
}
let file = "test_ls_context_file";
let expected = format!("unconfined_u:object_r:user_tmp_t:s0 {}\n", file);
let (at, mut ucmd) = at_and_ucmd!();
at.touch(file);
ucmd.args(&["-Z", file]).succeeds().stdout_is(expected);
}
#[test]
#[cfg(feature = "feat_selinux")]
fn test_ls_context2() {
use selinux::{self, KernelSupport};
if selinux::kernel_support() == KernelSupport::Unsupported {
println!("test skipped: Kernel has no support for SElinux context",);